Remote function call component init?

When a components remote function is called how is the component instantiated? Or, more to my need, is there an event (outside of onCFCRequest) or method in the component itself that is called when the remote function is called? I’d like to be able to set a component-level variable when a remote method is invoked.


Full disclosure I haven’t used remote CFC’s in years (I stick to REST these days), that said however… if my memory serves me correctly a remote component’s init() function is called when it’s instantiated just like any other CFC, so you should just be able to put your variables there (e.g. variables.myVariable = 'foo') and then use it elsewhere in other functions.

Or you could use property name="myVariable" type="myType" default="myValue"; in the component definition and achieve the same results. And doing this you could set acceessors=true in the component and use getMyVariable() in other functions (or simply variables.myVariable if you prefer not setting accessors=true).

Worse case you try it and I’m wrong, but I’m pretty sure a CFC is a CFC is a CFC in terms of instantiation.

EDIT: Actually, I was using Taffy for awhile a couple years ago, which uses remote methods in CFCs now that I think about it, and I’m pretty sure I did this kind of thing on the regular.


– Denny

@Jonathan_Brookins - The way I’ve seen a remote call to a CFC is in the following manner

//initiate your ajax code here
jax = setAJAX();

jax.onreadystatechange = processAJAX();“get”,"path_to_your_cfc.cfc?method=the_method_name&thevariable=+ the_variable, true);

if you had multiple variables you’d need to add the additional into the string.

The only thing you need to do make sure your cfc method is to make sure the access property is set to remote.

<cffunction name="the_method_name" access="remote">


remote any the_method_name();