|
Pardon my potentially colossal ignorance here, but -
If in a cfm page I do this:
// instantiate the Egg component variables.eggs = createObject("component","myPath/eggs");
// use it here to create a new Egg record variables.args = structNew(); variables.args.myArg1 = "blah"; variables.nEggs = variables.eggs.newEgg(argumentCollection=variables.args);
And - newEggs() within eggs.cfc looks something like this:
<cffunction name="newEgg" ...>
<cfargument name="myArg1" ...> <cfargument name="myArg2" ...>
<cfquery name="variables.insertEggs" ...> INSERT ... </cfquery>
Now - right here, after the insert query, I want to check and see if the insert itself happened and the new record exists, so ---
My question is - when I'm inside of newEgg() within egg.cfc, which was instantiated on the calling page, and newEgg() calls getEgg(), do I need to instantiate egg.cfc again since the component itself may not be aware of the fact that it was instantiated on the calling page, or what?
One example of the code following the insert query might be:
<cfscript> // instantiate the component instance.eggs = createObject("component","myPath/eggs"); // use it to check to see if the new Egg record exists instance.args.eggID = arguments.myArg1; instance.newEggCheck = instance.eggs.getEgg(instance.args.eggID);
// toggle return variable based on results of above test if(instance.createFacilityCheck.recordCount IS 1) instance.theReturnString = instance.theNewEggID; else instance.theReturnString = "ERROR"; </cfscript>
<cfreturn instance.theReturnString />
</cffunction>
Or, does it/should it know the object exists already? Something like this:
<cfscript> // check to see if the new Egg record exists instance.args.eggID = arguments.myArg1; instance.newEggCheck = instance.eggs.getEgg(instance.args.eggID);
// toggle return variable based on results of above test if(instance.createFacilityCheck.recordCount IS 1) instance.theReturnString = instance.theNewEggID; else instance.theReturnString = "ERROR"; </cfscript>
<cfreturn instance.theReturnString />
</cffunction>
Is that clear? Am I on crack? Ideas?
Thanks.
DM
|
- RE: [CFCDev] calling a component from within the itsel... David K. McCutcheon
- RE: [CFCDev] calling a component from within the ... Bryan F. Hogan
- RE: [CFCDev] calling a component from within ... David K. McCutcheon
- RE: [CFCDev] calling a component from wit... Bryan F. Hogan
- RE: [CFCDev] calling a component from... David K. McCutcheon
- RE: [CFCDev] calling a component from within the ... Dawson, Michael
