|
Thank you for the opportunity to demonstrate cfcPowerTools
last night. I am grateful for the opportunity. One thing I forgot to point out with cfcPowerTools and my
dataServices.cfc is that I can instantiate a CFC from a form submission.
It was brought up last night the need to be able to have a form submission work
with different CFCs. This is possible with cfcs using dataServices.
The basic concept is on your action page from your form submission you would
create structures containing the data from the form submission. You would
group the data from the form submission into structures then instantiate the
different CFCs and pass the appropriate structure to the init method. The
init method will pick out the keys of the structure that match the CFC’s
properties and populate the property with the data associated with the key.
It would look something like this: <cfscript> oCFC1 = createobject(“componet”,”cfc1”); oCFC2 = createobject(“componet”,”cfc2”); //write fields 1 and 2 to XXX table struct1 = structnew(); struct1.field1 = form.field1; struct1.field2 = form.field2; oCFC1.init(stData= struct1); oCFC1.save(); //write fields 3 and 4 to YYY table struct2 = structnew(); struct2.field3 = form.field3; struct2.field4 = form.field4; oCFC2.init(stData= struct2); oCFC2.save(); </cfscript> Thanks - Tom |
