One possibly minor point:
When you use CFINCLUDE to populate elements of your CFC I've found that it's
harder to keep track of locally (var) scoped variables. Since the variables
would have to be declared before the CFINCLUDE you have to remember to
maintain this information in two places (declare the variable in the CFC
then use it in the include).
The method I use to get around is to define a structure at the method like
so:
<cfset var local = structNew()>
Then I create all of my internal variables inside that structure: in effect
creating my own named scope in side the unnamed scope.
Instead of saying <CFQUERY name="foo"...> you'd say <CFQUERY
name="local.foo"...> for example.
This has greatly simplified my development and improved the stability of my
apps - it's a much easier habit to get into than remembering to declare
variables in another file.
As for using CFCs to output HTML - go for it. CFCs are just another
extension option they don't, themselves, have any limitations on the type of
logic you can place in them.
Good application development ("good" being a relative term mostly dependent
on the methodology you're using) generally provides guidelines for
functional separations between types of logic (data, business rules and
presentation, etc).
Any of those can be done using CFCs since a CFC is just a tool for
encapsulating code and data. You can build a well-designed, perfectly sound
application using only CFCs, using some CFCs or using no CFCs.
Jim Davis
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Andrew Scott
> Sent: Friday, January 09, 2004 1:27 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] CFC question and HTML in cfc
>
> Sean,
>
> I really wasn't looking for a how too, more of a guide if it was ok or
> not.
> I wrote the CFC's, but was looking at expaniding certain logic. In this
> case, I wasn't sure if it was frowned upon and was looking if others had
> considered putting HTML outputting like this into CFC's. In this case the
> code to generate this displays to the browser as well as being able to
> email, and I thought if I wrote this in a CFC instead of a custom tag I
> could give the application maybe a bit more of an upgrade path in the
> future
> rather than using custom tags.
>
>
>
> Regards
> Andrew Scott
> Technical Consultant
>
> NuSphere Pty Ltd
> Level 2/33 Bank Street
> South Melbourne, Victoria, 3205
>
> Phone: 03 9686 0485 - Fax: 03 9699 7976
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Sean A Corfield
> Sent: Friday, 9 January 2004 4:46 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [CFCDev] CFC question and HTML in cfc
>
> On Jan 7, 2004, at 7:57 PM, Andrew Scott wrote:
> > In regards to components and functions etc., I am looking at creating
> > a function to be generic to emails. Now should I create code in the
> > cfc to format the email or do an include for this.
>
> Consider something like this (untested idea):
>
> <cffunction name="sendEmail" ..>
> <cfargument name="template" type="string" ..>
> ...
> <!--- put data in request.someStruct --->
> <cfsavecontent variable="body">
> <cfinclude template="/emails/#arguments.template#.cfm">
> </cfsavecontent>
> <!--- send email with #body# --->
> </cffunction>
>
> Now the email formatting is all in a separate set of files and the CFC is
> "clean". You'd need something more complex for both HTML and plain text
> email, but the same principle applies.
>
> Hope that helps?
>
> Sean A Corfield -- http://www.corfield.org/blog/
>
> "SOAP is not so much a means of transmitting data but a mechanism for
> calling COM objects over the Web."
> -- not Microsoft (surprisingly!)
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
> Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at www.mail-
> archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]