It is
also a great solution for dynamic code where you want to call different methods
with different parameters using a single line of code. For instance, imagine you
want to run unit testing on your entire model. Load all of the testing into a
database with the methods, tests, parameter names and values and the expected
returns and you can write your own entry level unit testing framework
in about an hour. You can also reuse the test data across projects by having a
project to test joining table and all of the tests can be run using a single
dynamic createObject with an argumentCollection. Very cool example of the
flexibility that argumentCollection allows!
Best
Wishes,
Peter
Peter
---------------------------------------------------------------Original Message-----Don't forget argumentcollection as an alternative.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Williams
Sent: Friday, June 23, 2006 6:50 PM
To: [email protected]
Subject: Re: [CFCDev] Question About Invoking/Creating CFC Objects
<cfset args = structNew() />
<cfset args.myVariable = "some value" />
<cfset args.myOtherVariable = "another value" />
<cfset myObject = createObject('component','myObject').init(myDSN) />
<cfset qry_Products = myObject.getProducts(argumentCollection=args) />
This method can be nice if you want to pass in an entire form. Say you have a search form. It's field names match those of the parameters in your search function in your CFC.
Then after instantiating you can do
<cfset qry_Products = myObject.getProducts(argumentCollection=Form) />
Excess Form Fields such as the Submit button or the FieldList are just ignored.
--
Matt Williams
"It's the question that drives us." ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
