Solved

Calling a CFC directly from a form

Posted on 2008-10-30
3
353 Views
Last Modified: 2012-05-05
Is it possible to call a CFC directly from the action tag in <cfform>?

if not what is the best way to invoke the cfc from a form?


Thanks,
0
Comment
Question by:Hulfy
  • 2
3 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 500 total points
ID: 22844471
yes you can

<form method="post" action="com/myCFC.cfc?method=yourFunction">

however best practice says when designing cfc's, all input should be agnostic (to allow for other potential inputs like web services) and should use arguments

to do this create a form handler

<form method="post" action="actFormHandler.cfm">

<input type=="hidden" name="formid" value="f1">
<input type="submit">
</form>
then

in actFormHandler.cfm

<cfswitch expression="form.formid">

<cfcase value="f1">
<cfinvoke component="com.myCfc"
                  method="doFormPost1"
                  ReturnVariable = "results">
      <cfinvokeargument name="ID" value="#form.ID#">            
      <cfinvokeargument name="value2" value="#form.value2#">            
</cfinvoke>      
</cfcase>

etc

note in either case you need to add access="remote" to your cfc function







0
 
LVL 36

Expert Comment

by:SidFishes
ID: 22844490
oh and if you're not already use arguments in the cffunction


<cffunction name="doFormPost1" hint="I process a form"
                  returntype="void">
      <cfargument name="ID" required="true">
      <cfargument name="value2" required="true">

<!--- do stuff --->
</cffunction>

0
 

Author Comment

by:Hulfy
ID: 22848151
Thanks Sid
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now