Ah! Thanks Charlie! This makes sense now. I was not using the createObject function right in my last try.
Thanks again! -----Original Message----- From: Charlie Griefer [mailto:[EMAIL PROTECTED] Sent: Thursday, June 07, 2007 12:09 PM To: CF-Talk Subject: Re: invoking a cfc function with minimal typing On 6/7/07, Chad Gray <[EMAIL PROTECTED]> wrote: > Oh wow.. that looks powerful. They are form fields. > > I get this error "Variable COM is undefined." when trying it. I must have my > cfc's not configured right. > > <cfset com.mysite.ticketdata.updateTable(argumentcollection=form) /> > > If I use cfinvoke I format my component with "dots" > <cfinvoke component="com.mysite.ticketdata" method="updateTable"> > > What do I need to do to use cfset with my cfc? <cfset myInstanceName = createObject('component', 'com.mysite.ticketdata') /> <cfset myInstanceName.updateTable(argumentcollection=form) /> obviously, 'myInstanceName' can be any variable name. bear in mind that createObject() is a relatively expensive process. if the component has methods that will be called frequently throughout the application, it might be a good idea to instantiate it into the application scope. this way you're just doing a createObject() once, but can refer to the methods within the component as many times as needed within the application. for example... wherever you'd normally set your session/application variables: <cfset application.myComponent = createObject('component', 'com.mysite.ticketdata') /> then on your form's action page: <cfset application.myComponent.updateTable(argumentcollection=form) /> > -----Original Message----- > From: Charlie Griefer [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 07, 2007 11:38 AM > To: CF-Talk > Subject: Re: invoking a cfc function with minimal typing > > if you're sending form fields... > > <cfset myInstance.updateTable(argumentcollection=form) /> > > you can send an array, you can send a struct... you can send any > number of simple variables wrapped up in a single complex var. > > On 6/7/07, Chad Gray <[EMAIL PROTECTED]> wrote: > > I have a function in a CFC that does an update on a database table. > > > > <cffunction name="updateTable" access="public"> > > <cfargument name="id" type="numeric" required="yes"> > > <cfargument name="Feild1" type="string" required="no"> > > <cfargument name="Field2" type="string" required="no"> > > > > <cfquery datasource="#variables.dataSource#"> > > UPDATE table SET > > Field1='#arguments.Field1#', > > Field2='#arguments.Field2#' > > WHERE id = #arguments.id# > > </cfquery> > > </cffunction> > > > > > > I can use <cfinvoke> with cfinvokearguments tags for each field, but that > > is a lot of typing. > > > > What is best way to send the arguments to the function with the least > > amount of typing? > > > > I suppose is my real question is how do you use cfscript to send the data? > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:280398 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

