Jaime .... interesting question, and yes, the CFC in this case is
stored in the session scope.
Andrew ... for a lot of reasons, I chose to have the "view" layer
implemented in a CFC. The application is set up such that a user
creates their own templates, and then uses keywords inside those
templates which are equivalent to various widgets, etc. For example,
the user might put the following into their template, which is stored
in the database:
<html>
<head>
%title%
other stuff
</head>
<body>
some header and formatting stuff
%blog_entry% <!--- this indicates that the render method should
execute the blog_entry method and display the results here.--->
some footer and formatting stuff
</body>
All of the above is stored in the database. When the page is
actually executed, the OnRequest in application CFC looks something
like this:
<cffunction name="OnRequest" returntype="void" output="true">
<cfargument name="thePage" type="string" required="true">
<!--- this line determines the appropriate template to use based on
the customer org id and the request variables --->
<CFSET VAR TEMPLATE=APPLICATION.RS.GETTEMPLATE(RSORGANIZATION.ORGID,
REQUEST.RQ.PAGE)>
<!--- this line passes the template and request variables into a page
processing CFC --->
<CFOUTPUT>#APPLICATION.PG.RENDER(TEMPLATE, REQUEST.RQ)#</CFOUTPUT>
So this calls a function that determines which of those templates to
use, then renders it, calling the correct routines on the fly. So
basically all of the content in any given user website is driven by
the render method in the page processing CFC. I ended up building it
this way because the app was a nightmarish chaos of code before.
While I appreciate the suggestion to separate out the page processing
into CFM templates, I've just spent about six months undoing that, so
it's not really an option at this point. That said, the "view" CFCs
are separated out from the business logic, but yes, it's completely
CFC driven. I don't have any CFM templates in the entire app.
>
> Also, I know that was only pseudocode, but given that "var" is a
> reserved
> word it looks a bit dodgy. You'd want to at least var scope that
> result
> variable, e.g.
>
> <cfset var result = "">
^^^^ Correct here, I mistyped in my orriginal email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Enterprise web applications, build robust, secure
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288076
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4