CFCs for AJAX

2010-11-16 Thread Donnie Carvajal
I have several CFCs that I am accessing for AJAX calls. Since the calls load a method directly, what is the best practice for instantiating the object? For example, I want to insure the user is logged in, so there are Client variables to check, I don't want to pass user credentials in the

Re: CFCs for AJAX

2010-11-16 Thread Tony Bentley
Ajax Call - OnRequest() - checkUserCredentials.init(client){abort or continue} ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive:

Re: CFCs for AJAX

2010-11-16 Thread Tony Bentley
I would do user checks in a component from onRequest and then use a proxy cfc for your ajax requests. Using onRequest, you can check the url and if it is the proxy cfc, then do your user credential checks before allowing access. Otherwise, you'll need to use the client scope in your cfc

Re: CFCs for AJAX

2010-11-16 Thread Donnie Carvajal
I thought the onRequest method caused issues with calling CFCs remotely. I heard CF 9 fixed, but I'm not using CF 9. I guess this would work in the onRequestStart method though. Is this correct? I would do user checks in a component from onRequest and then use a proxy cfc for your ajax

Re: CFCs for AJAX

2010-11-16 Thread Tony Bentley
Even if it is a remote cfc call it's still a request that fires onSessionStart() and onRequestStart(). I'm not sure what kind of issues you've heard but it works with me in CF8.0.1+ ~| Order the Adobe Coldfusion Anthology

Re: CFCs for AJAX

2010-11-16 Thread Tony Bentley
Shoot. Sorry, I meant to say onRequestStart() not onRequest. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive:

Re: CFCs for AJAX

2010-11-16 Thread Donnie Carvajal
I figured it was a typo. I get the credential check in the onRequestStart(), makes sense. The other issue I'm having is that I need to access the user object that would be created in onRequestStart(). Basically, CF based objects can't be passed to remote methods, correct? So either way, I

Re: CFCs for AJAX

2010-11-16 Thread Ian Skinner
On 11/16/2010 12:06 PM, Donnie Carvajal wrote: I thought the onRequest method caused issues with calling CFCs remotely. Can cause problems. The problem usually being that the onRequest, onRequestStart and|or onRequestEnd cause data to be added to the request response that AJAX can not

Re: CFCs for AJAX

2010-11-16 Thread Tony Bentley
If you avoid any output in any application methods then it will work fine and any Ajax framework (JQuery, JSON.js, etc) can convert the returned code to native JSON. This is why I said invoke a cfc and pass in the scope(s) of choice in your onRequestStart method. Can cause problems.  The

Re: CFCs for AJAX

2010-11-16 Thread James Holmes
Create a proxy (or facade) object that you can call via AJAX. In this object you can access the instantiated objects that are in the session or application scope. As long as you know that only this one proxy object accesses those scopes directly (and in fact that's its purpose) then you won't run