There are reasons to use CFCs to create output.    For example i had an
application that required an output of a quite large XML file made up of
maybe 50 fragments of XML,  out of a possible 300 or so specially formatted
fragments.    Each occasion the XML was created,  the logic CFC would call
the appropriate functions in the output cfc, which would produce the
relevant fragment of that XML packet, then the logic CFC would stitch them
all together into one XML packet and return it to the calling page.

In XML, if you have white space in the wrong place, it can make the whole
XML packet invalid, so this was a serious issue for the viability of the
whole application.   And as i posted in my previous email in this thread, it
worked just fine,  producing output from the CFC with no extra white space.
 But you can't just treat it as a normal cfml page inside a cfc.   You have
to create a variable, containing the bit of html you want to output,  then
pass that back to the calling page.   Otherwise,  as you've found,  you'll
get all kinds of extra white space.

As it happened, my XML packets ended up having no spaces AT ALL in them,
except for intentional spaces between words in the values of the fields.
So i know you can do what you are seeking to do.

Another application for CFCs producing output is my CF9 code generator.   I
have a CFC that examines a database table, then calls a whole series of cfc
methods,  each of which produces a fragment of code, and the logic CFC
stitches them together and writes them out to a file (or files).   Kind of
like my own form of ORM,  that i wrote before i had ever heard of the term
ORM.

You can do what you want, but as others have said I'd advise putting the
logic in one CFC, and the actual output generation in another,  just so you
organise your code.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month



On Fri, Aug 6, 2010 at 2:16 AM, Sean Corfield <seancorfi...@gmail.com>wrote:

>
> On Thu, Aug 5, 2010 at 7:13 AM, Robert Harrison
> <rob...@austin-williams.com> wrote:
> > I've moved output function into CFC's; thus I'm using output="true". Only
> > problem is the CFC is outputting whitespace where all the logic is now.
> >
> > How can I suppress the white space in an output CFC?
>
> Write the CFC entirely in cfscript (which generates no spurious
> whitespace) and use writeOutput() around the stuff you want to output.
>
> But, as others have noted, really the 'best practice' is CFCs for
> logic, CFM pages for output - mainly since you don't want to be mixing
> HTML (display) in with your logic.
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies, Inc. -- http://getrailo.com/
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336048
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to