Need Database Call Understanding...

View: New views
17 Messages — Rating Filter:   Alert me  

Need Database Call Understanding...

by Kim Hoopingarner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am new to Flex - but been a Coldfusion programmer for a few years now.  I am trying to make some sense out of how the Flex wizard creating the coldfusion CFC's is advantageous.  It creates 2 layers (bean/DAO) - one is the Gateway file that is basically calling functions in the DAO.  

Is there an advantage to calling this 2-CFC-sequence instead of calling 1 single CFC?  I know that these CFC's are created in a slick way to minimize programmer efforts in coding.  But I question the efficiency...

Thanks for clearing the mystery!
Kim

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5826
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Need Database Call Understanding...

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I am new to Flex - but been a Coldfusion programmer for a few years now.  I am trying to
> make some sense out of how the Flex wizard creating the coldfusion CFC's is
> advantageous.  It creates 2 layers (bean/DAO) - one is the Gateway file that is basically
> calling functions in the DAO.
>
> Is there an advantage to calling this 2-CFC-sequence instead of calling 1 single CFC?  I
> know that these CFC's are created in a slick way to minimize programmer efforts in coding.
> But I question the efficiency...

I really wouldn't worry about the inefficiency there. The much bigger
inefficiency is the use of beans on the server to represent the
individual records, but the advantage of doing this is that you can
then use corresponding value objects on the client and take full
advantage of the OO model in Flex.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more informati

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5827
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Need Database Call Understanding...

by Kim Hoopingarner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


OK, makes sense.  So the advantage is the use of the strong names in the code.  I thought there was something really techie involved with the CF server that made gateway/dao run better than a single file with multiple cfquery's within.

Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5828
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Need Database Call Understanding...

by Mike Nimer-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The reason it generates bean/dao, is only because it's a common design  
pattern. That a lot of frameworks use. So by using bean/dao (and the  
wizards also create Active Record style CFCs too if you only want one  
cfc) you can plug them right into a known framework.

---nimer


On Mar 22, 2009, at 1:00 PM, Dave Watts wrote:

>
>> I am new to Flex - but been a Coldfusion programmer for a few years  
>> now.  I am trying to
>> make some sense out of how the Flex wizard creating the coldfusion  
>> CFC's is
>> advantageous.  It creates 2 layers (bean/DAO) - one is the Gateway  
>> file that is basically
>> calling functions in the DAO.
>>
>> Is there an advantage to calling this 2-CFC-sequence instead of  
>> calling 1 single CFC?  I
>> know that these CFC's are created in a slick way to minimize  
>> programmer efforts in coding.
>> But I question the efficiency...
>
> I really wouldn't worry about the inefficiency there. The much bigger
> inefficiency is the use of beans on the server to represent the
> individual records, but the advantage of doing this is that you can
> then use corresponding value objects on the client and take full
> advantage of the OO model in Flex.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more informati
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5829
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,
This issue is driving me a little nuts.

I'm building a web based API to my database. I POST some data from  
Flex (or FMS), I get back XML. That works pretty well (but note I am  
not a CF programmer by trade...).

What I'm struggling with is suppressing all the whitespace in the XML.  
My CFM page essentially looks like this (simplified):

<cfsetting enablecfoutputonly="yes">
<cfprocessingdirective pageencoding = "utf-8" suppressWhiteSpace =  
"Yes">

<cfxml variable="userXML">
        <cfoutput><result action="none" status="error"></cfoutput>
        <cfoutput><message>no action defined</message></cfoutput>
        <cfoutput></result></cfoutput>
</cfxml>

<cfoutput>#toString(userXML)#</cfoutput>
</cfprocessingdirective>

If I hit this from FMS and trace the response I see this:


<?xml version="1.0" encoding="UTF-8"?>

<result action="none" status="error"><message>no action defined</
message></result>


It has a big fat empty line between the first and second line of  
content (I assume the first line is added on the fly by CF by me  
setting the page encoding).

I'm wondering what suppressWhiteSpace = "Yes" actually does because  
intially I did not wrap each line of my output in cfoutput tags, but  
that resulted in all the tab intends to be outputted as well.

Are there any best practices on how to format XML responses in CF?

And one more question: what exactly is returned to me if I omit the  
toString conversion on the last line (toString(userXML)) ? My FMS  
trace shows
coldfusion.xml.XmlNodeList@140e0f2
and I have no clue how I could then process that, which is why I ended  
up with toString (note FMS uses ActionScript 1 so I do not have the  
luxuries of E4X and the like for parsing, instead FMS is very picky  
when it comes to XML formatting).

Cheers

Stefan







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5830
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I'm building a web based API to my database. I POST some data from
> Flex (or FMS), I get back XML. That works pretty well (but note I am
> not a CF programmer by trade...).
>
> What I'm struggling with is suppressing all the whitespace in the XML.
> My CFM page essentially looks like this (simplified):
>
> <cfsetting enablecfoutputonly="yes">
> <cfprocessingdirective pageencoding = "utf-8" suppressWhiteSpace =
> "Yes">
>
> <cfxml variable="userXML">
>        <cfoutput><result action="none" status="error"></cfoutput>
>        <cfoutput><message>no action defined</message></cfoutput>
>        <cfoutput></result></cfoutput>
> </cfxml>
>
> <cfoutput>#toString(userXML)#</cfoutput>
> </cfprocessingdirective>
>
> If I hit this from FMS and trace the response I see this:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <result action="none" status="error"><message>no action defined</
> message></result>
>
> It has a big fat empty line between the first and second line of
> content (I assume the first line is added on the fly by CF by me
> setting the page encoding).
>
> I'm wondering what suppressWhiteSpace = "Yes" actually does because
> intially I did not wrap each line of my output in cfoutput tags, but
> that resulted in all the tab intends to be outputted as well.
>
> Are there any best practices on how to format XML responses in CF?

In your example code, you don't need any of the CFOUTPUT tags except
the last one. CFXML lets you build an XML document object in memory.

That said, I don't know if that'll affect your whitespace output. In
my experience, I usually find it's easier just to get rid of
whitespace at design time if I care about it, which I might in the
case of XML.

> And one more question: what exactly is returned to me if I omit the
> toString conversion on the last line (toString(userXML)) ? My FMS
> trace shows
> coldfusion.xml.XmlNodeList@140e0f2
> and I have no clue how I could then process that, which is why I ended
> up with toString (note FMS uses ActionScript 1 so I do not have the
> luxuries of E4X and the like for parsing, instead FMS is very picky
> when it comes to XML formatting).

FMS uses ActionScript 1 still? Yikes!

Anyway, CFXML creates an XML document object in memory. You can't just
output one of those as a string; when you do, you get the funky syntax
you saw. That is basically telling you that there's an object of type
coldfusion.xml.XmlNodeList at a certain location in memory.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5831
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> If I hit this from FMS and trace the response I see this:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <result action="none" status="error"><message>no action defined</
> message></result>
>
> It has a big fat empty line between the first and second line of
> content (I assume the first line is added on the fly by CF by me
> setting the page encoding).

I missed this part in my initial response, but the first line is added
by CFXML automatically.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5832
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks Dave.
So basically I am not doing anything inherently wrong, correct?

When you say 'easier just to get rid of
> whitespace at design time if I care about it, '
what do you mean by that? Design time as in when it arrives on the FMS  
side?

I'll also take your advice and try to put my cfoutput tags on a diet!

Cheers

Stefan







On 24 Mar 2009, at 13:12, Dave Watts wrote:

>
>> I'm building a web based API to my database. I POST some data from
>> Flex (or FMS), I get back XML. That works pretty well (but note I am
>> not a CF programmer by trade...).
>>
>> What I'm struggling with is suppressing all the whitespace in the  
>> XML.
>> My CFM page essentially looks like this (simplified):
>>
>> <cfsetting enablecfoutputonly="yes">
>> <cfprocessingdirective pageencoding = "utf-8" suppressWhiteSpace =
>> "Yes">
>>
>> <cfxml variable="userXML">
>>        <cfoutput><result action="none" status="error"></cfoutput>
>>        <cfoutput><message>no action defined</message></cfoutput>
>>        <cfoutput></result></cfoutput>
>> </cfxml>
>>
>> <cfoutput>#toString(userXML)#</cfoutput>
>> </cfprocessingdirective>
>>
>> If I hit this from FMS and trace the response I see this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <result action="none" status="error"><message>no action defined</
>> message></result>
>>
>> It has a big fat empty line between the first and second line of
>> content (I assume the first line is added on the fly by CF by me
>> setting the page encoding).
>>
>> I'm wondering what suppressWhiteSpace = "Yes" actually does because
>> intially I did not wrap each line of my output in cfoutput tags, but
>> that resulted in all the tab intends to be outputted as well.
>>
>> Are there any best practices on how to format XML responses in CF?
>
> In your example code, you don't need any of the CFOUTPUT tags except
> the last one. CFXML lets you build an XML document object in memory.
>
> That said, I don't know if that'll affect your whitespace output. In
> my experience, I usually find it's easier just to get rid of
> whitespace at design time if I care about it, which I might in the
> case of XML.
>
>> And one more question: what exactly is returned to me if I omit the
>> toString conversion on the last line (toString(userXML)) ? My FMS
>> trace shows
>> coldfusion.xml.XmlNodeList@140e0f2
>> and I have no clue how I could then process that, which is why I  
>> ended
>> up with toString (note FMS uses ActionScript 1 so I do not have the
>> luxuries of E4X and the like for parsing, instead FMS is very picky
>> when it comes to XML formatting).
>
> FMS uses ActionScript 1 still? Yikes!
>
> Anyway, CFXML creates an XML document object in memory. You can't just
> output one of those as a string; when you do, you get the funky syntax
> you saw. That is basically telling you that there's an object of type
> coldfusion.xml.XmlNodeList at a certain location in memory.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5833
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> So basically I am not doing anything inherently wrong, correct?

No, not really.

> When you say 'easier just to get rid of whitespace at design time if I care about it, '
> what do you mean by that? Design time as in when it arrives on the FMS side?

No, I mean on the CF side:

<cfxml variable="userXML"><result action="none"
status="error"><message>no action defined</message></result></cfxml>

<cfcontent reset="yes"><cfoutput>#userXML#</cfoutput>

The CFCONTENT tag will clear the output buffer so that you don't have
any whitespace from the previous empty lines.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5834
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks again, I will try that.

I have not managed to do away with the cfoutput tags however since  
often my XML return contains dynamically generated values, I think I  
therefore need the cfoutput.

But I discovered something else - and this is almost too stupid to  
comprehend and should be written on a warning sign when you install  
CF: in the CF admin under settings there is an option ‘Enable  
Whitespace Management’.  Guess what - it wasn't checked. Seems  
unchecked by default.

Checking it seems to eliminate *a lot* of leading whitespace issues I  
had. Could it be that without this checked the suppressWhiteSpace  
option of cfprocessingdirective does nothing at all?

Regards,

Stefan




On 24 Mar 2009, at 16:10, Dave Watts wrote:

>
>> So basically I am not doing anything inherently wrong, correct?
>
> No, not really.
>
>> When you say 'easier just to get rid of whitespace at design time  
>> if I care about it, '
>> what do you mean by that? Design time as in when it arrives on the  
>> FMS side?
>
> No, I mean on the CF side:
>
> <cfxml variable="userXML"><result action="none"
> status="error"><message>no action defined</message></result></cfxml>
>
> <cfcontent reset="yes"><cfoutput>#userXML#</cfoutput>
>
> The CFCONTENT tag will clear the output buffer so that you don't have
> any whitespace from the previous empty lines.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more information!
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5835
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I have not managed to do away with the cfoutput tags however since
> often my XML return contains dynamically generated values, I think I
> therefore need the cfoutput.

That makes sense.

> But I discovered something else - and this is almost too stupid to
> comprehend and should be written on a warning sign when you install
> CF: in the CF admin under settings there is an option ‘Enable
> Whitespace Management’.  Guess what - it wasn't checked. Seems
> unchecked by default.

Right, this is disabled by default. For most uses - HTML generation,
for example - this simply isn't that important. And it does add some
overhead.

> Checking it seems to eliminate *a lot* of leading whitespace issues I
> had. Could it be that without this checked the suppressWhiteSpace
> option of cfprocessingdirective does nothing at all?

No, the two are separate. However, if I recall correctly,
CFPROCESSINGDIRECTIVE only gets rid of white space generated by CF
tags. It doesn't get rid of the line where the CF tag was, so you end
up with blank lines. Also, and I hadn't noticed this in your original
email, you're not supposed to use both PAGEENCODING and
SUPPRESSWHITESPACE attributes in the same CFPROCESSINGDIRECTIVE tag.

Again, though, my preference is to use CFCONTENT TYPE="RESET" to avoid
leading whitespace before my output, when generating non-HTML output.

Finally, all this is easily avoided if you can use either web services
or Flash Remoting with CF. CF supports both. But you did mention that
you're using FMS, and I don't know enough about that to comment.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more informati

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5836
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Ian Skinner-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Here is one way I have dealt with this issue.

<cfsilent>
    <cfquery name="markers" datasource="sor">
        SELECT
            l.id,
            l.name AS location,
            l.lead,
            l.longitude,
            l.latitude,
            a.name AS activity,
            j.ranking,
            r.stars,
            r.rank,
            a.icon
           
        FROM
            locations l INNER JOIN
                location_activity_join j ON l.id = j.locationID INNER JOIN
                    activities a ON j.activityID = a.id INNER JOIN
                        location_activity_ranks r ON j.ranking = r.id
               
        WHERE
            published = 1
           
        ORDER BY
            l.name
    </cfquery>
</cfsilent><cfcontent type="text/xml" reset="yes"><?xml version="1.0"
encoding="iso-8859-1"?>
<markers><cfoutput query="markers" group="location"><cfset
cat=''><marker lng="#val(longitude)#" lat="#val(latitude)#" id="#id#"
name="#xmlFormat(trim(location))#" category="<cfoutput><cfset cat =
#listAppend(cat,xmlFormat(rereplace(trim(activity),'[^[:alnum:]]','','ALL')))#></cfoutput>#cat#"
activities="<cfoutput>#xmlFormat(trim(activity))#
#repeatString('*',val(stars))#<br/></cfoutput>" />
</cfoutput>
</markers>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5837
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks, would love to use Remoting but this project will end up as a  
public API over HTTP and I need to hit it from FMS too (which btw can  
do Remoting if needed).

Cheers

Stefan




On 24 Mar 2009, at 17:36, Dave Watts wrote:

>
>> I have not managed to do away with the cfoutput tags however since
>> often my XML return contains dynamically generated values, I think I
>> therefore need the cfoutput.
>
> That makes sense.
>
>> But I discovered something else - and this is almost too stupid to
>> comprehend and should be written on a warning sign when you install
>> CF: in the CF admin under settings there is an option ‘Enable
>> Whitespace Management’.  Guess what - it wasn't checked. Seems
>> unchecked by default.
>
> Right, this is disabled by default. For most uses - HTML generation,
> for example - this simply isn't that important. And it does add some
> overhead.
>
>> Checking it seems to eliminate *a lot* of leading whitespace issues I
>> had. Could it be that without this checked the suppressWhiteSpace
>> option of cfprocessingdirective does nothing at all?
>
> No, the two are separate. However, if I recall correctly,
> CFPROCESSINGDIRECTIVE only gets rid of white space generated by CF
> tags. It doesn't get rid of the line where the CF tag was, so you end
> up with blank lines. Also, and I hadn't noticed this in your original
> email, you're not supposed to use both PAGEENCODING and
> SUPPRESSWHITESPACE attributes in the same CFPROCESSINGDIRECTIVE tag.
>
> Again, though, my preference is to use CFCONTENT TYPE="RESET" to avoid
> leading whitespace before my output, when generating non-HTML output.
>
> Finally, all this is easily avoided if you can use either web services
> or Flash Remoting with CF. CF supports both. But you did mention that
> you're using FMS, and I don't know enough about that to comment.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more informati
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5838
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks Ian.

I'm getting satisfactory results now by using:

<cfprocessingdirective suppressWhiteSpace = "Yes">
<cfsetting enablecfoutputonly="yes">

combined with the checked box in the CF Admin and
<cfcontent type="text/xml" reset="yes"

before my output.


Thanks all.



On 24 Mar 2009, at 18:38, Ian Skinner wrote:

>
> Here is one way I have dealt with this issue.
>
> <cfsilent>
>    <cfquery name="markers" datasource="sor">
>        SELECT
>            l.id,
>            l.name AS location,
>            l.lead,
>            l.longitude,
>            l.latitude,
>            a.name AS activity,
>            j.ranking,
>            r.stars,
>            r.rank,
>            a.icon
>
>        FROM
>            locations l INNER JOIN
>                location_activity_join j ON l.id = j.locationID INNER  
> JOIN
>                    activities a ON j.activityID = a.id INNER JOIN
>                        location_activity_ranks r ON j.ranking = r.id
>
>        WHERE
>            published = 1
>
>        ORDER BY
>            l.name
>    </cfquery>
> </cfsilent><cfcontent type="text/xml" reset="yes"><?xml version="1.0"
> encoding="iso-8859-1"?>
> <markers><cfoutput query="markers" group="location"><cfset
> cat=''><marker lng="#val(longitude)#" lat="#val(latitude)#" id="#id#"
> name="#xmlFormat(trim(location))#" category="<cfoutput><cfset cat =
> #listAppend
> (cat
> ,xmlFormat(rereplace(trim(activity),'[^[:alnum:]]','','ALL')))#></
> cfoutput>#cat#"
> activities="<cfoutput>#xmlFormat(trim(activity))#
> #repeatString('*',val(stars))#<br/></cfoutput>" />
> </cfoutput>
> </markers>
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5839
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Thanks, would love to use Remoting but this project will end up as a
> public API over HTTP and I need to hit it from FMS too (which btw can
> do Remoting if needed).

SOAP is a public API, isn't it? You could write a single CFC method
which can be called via SOAP and Remoting, and offer either.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5840
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Stefan Richter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Yeah SOAP would be an option but since I'm not that familiar with it  
(and I'll have to support this thing) I'll stick to the custom XML  
responses for now.

Cheers

Stefan



On 24 Mar 2009, at 19:25, Dave Watts wrote:

>
>> Thanks, would love to use Remoting but this project will end up as a
>> public API over HTTP and I need to hit it from FMS too (which btw can
>> do Remoting if needed).
>
> SOAP is a public API, isn't it? You could write a single CFC method
> which can be called via SOAP and Remoting, and offer either.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5841
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Fighting with whitespace

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Yeah SOAP would be an option but since I'm not that familiar with it
> (and I'll have to support this thing) I'll stick to the custom XML
> responses for now.

Well, just for future reference, it's very simple. You just write a
CFC, add a function to that CFC with ACCESS="REMOTE", and return
whatever object you want to return. For cross-platform happiness,
stick to simple values, arrays or typed objects (essentially
structures for which you've created a corresponding CFC). You don't
have to write any XML at all that way.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5842
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37