1.

How Can You Invoke Cfc?

Answer»

Method 1:

<cfinvoke>
<cfinvoke component="user" method="Get"
returnvariable="usr">
<cfinvokeargument NAME="id" value="#id#">
</cfinvoke>

Method 2:

<!­­­ Load CFC as an object ­­­>
<cfobject component="user" name="userObj">
<!­­­ Invoke method ­­­>
<cfinvoke component="#userObj#" method="Get" id="#id#"
returnvariable="usr">
Method 3:

<cfscript>
// Load CFC as an object
userObj=CreateObject("component","user");

// Invoke method

user_id=userObj.Get(id);
</cfscript>

Method 4: URL Invocation : CFCs can also be invoked on the command line directly; EVERY CFC has a URL that POINTS to it. When invoking CFCs via URLs, the method and any arguments are passed as URL parameters, as seen here:

http://localhost/users/user.cfc?method=get&id=1

Method 1:

<cfinvoke>
<cfinvoke component="user" method="Get"
returnvariable="usr">
<cfinvokeargument name="id" value="#id#">
</cfinvoke>

Method 2:

<!­­­ Load CFC as an object ­­­>
<cfobject component="user" name="userObj">
<!­­­ Invoke method ­­­>
<cfinvoke component="#userObj#" method="Get" id="#id#"
returnvariable="usr">
Method 3:

<cfscript>
// Load CFC as an object
userObj=CreateObject("component","user");

// Invoke method

user_id=userObj.Get(id);
</cfscript>

Method 4: URL Invocation : CFCs can also be invoked on the command line directly; every CFC has a URL that points to it. When invoking CFCs via URLs, the method and any arguments are passed as URL parameters, as seen here:

http://localhost/users/user.cfc?method=get&id=1



Discussion

No Comment Found