Thanks for the reply, Brian.  I see what you mean about the
"agnosticism" of the view.

Thanks, also, for the tip on handling the session variables.
and the rest of the comments.

Another issue I've run into is how to help my calling page find
my cfc's.  While learning, I've just placed the cfc in the same
folder as the calling page.  But now I'm placing them in a components
folder and the calling page can't find it.

My current folder structure is a little strange because I have
a folder for subdomain templates inside main site's folder.

So I have my main site in this structure:
e:\inetpub\webroot\c21-ar\index.cfm

There is also a 'components' folder at:
e:\inetpub\webroot\c21-ar\components

My subdomains main folder is at:
e:\inetpub\webroot\c21-ar\agents

How can I run this page:
e:\inetpub\webroot\c21-ar\agents\index.cfm

and have it call a cfc at:
e:\inetpub\webroot\c21-ar\components\agents.cfc

???

Do I need to set up mappings in CF Admin or create a virtual
directory in IIS, perhaps?  I've tried numerous approaches,
but nothing has worked.

Thanks, again,

Rick

> -----Original Message-----
> From: Brian Kotek [mailto:[EMAIL PROTECTED]
> Sent: Sunday, June 15, 2008 9:19 PM
> To: CF-Talk
> Subject: Re: cfc question...
> 
> You should var-scope your query variable. Also, you can't just return 0 if
> the query has no data, since you have specified the return type as "query"
> and 0 is not a query. Finally, the function doesn't need to be
> access="remote" unless you plan to call this as a web service or through
> AMF.
> 
> 
> >
> > Now, let's say the invocation is successful and I have extracted query
> > data.
> > I know how to access all the query data back on the calling page (it seems
> > counter-intuitive that the <cfreturn> variable, 'get_agent' in my example
> > above,
> > is referenced or 'renamed as 'agent_info' as the returnvariable in the
> > <cfinvoke>...
> > why the renaming?).
> 
> 
> It's actually not counter-intuitive. Your calling code does not and should
> not know anything about the internal implementation of your method. So
> whatever variable you use within the method is not visible to anything
> outside of the method. This is encapsulation, and it is the most fundamental
> principle that underlies OOP. So nothing is actually "renamed"; when you
> call the method you are explicitly assigning the result to the variable
> "agent_info", the same way you would with any other variable assignment.
> 
> 
> > However, in my app I'm converting all the agent data from the query into
> > session
> > variables to customize my templates.
> >
> > Is there a way to do that in the .cfc or should I handle that back on my
> > calling .cfm page?
> > If I handle it in the .cfc, which I'd prefer in order to keep all
> > processing out of the
> > display page code, how would I return the session variables to the calling
> > page?
> >
> 
> This should be handled by the CFC, your views should be as agnostic as
> possible about how they are used. If you want to cache this in the session
> scope you could do something like:
> 
> <cffunction access='remote' name='get_agent_info' output='0'
> returntype='query'>
>     <cfargument name='agent_id' type='string' required='1'/>
>     <cfset var get_agent = "" />
> 
>     <cfif not StructKeyExists(session, 'get_agent')>
>     <cfquery name='get_agent' datasource='xxxxx'>
>          select * from our_agents where agent_id = '#arguments.agent_id#'
>     </cfquery>
>     <cfset session.get_agent = get_agent />
>     </cfif>
> 
>     <cfreturn session.get_agent/>
> 
> </cffunction>
> 
> Which will set the variable into the session scope the first time you call
> this method, but will return the value from the session scope for all
> subsequent requests within the same session.
> 
> Hope that helps,
> 
> Brian
> 



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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307531
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to