I like the idea of being able to get a list of args out of the event object. Might be a bit less typing then the copyToScope() help that is out there but would only work if you wanted to get stuff out of the event object.
--Kurt On Sat, Feb 12, 2011 at 7:29 AM, Joe Bodell <[email protected]> wrote: > Peter. > > Excellent use of the squirrelzipper structkey! > > I try too emphasize conventions like common argument/parameter names > from listeners down to the persistence layer (whether or not I stick > to thse conventions consistently is another matter) and so I was > thinking that this would help reinforce that concept by reducing the > number of cfsets before a call to my services. But as expected, you're > right that copytoscope would accomplish this goal, albeit a little > more verbosely :-) I also tend to lean on argumentcollection = > argstopass in method calls to make the calls look cleaner, and hadn't > really thought about treating a var'ed structure as a scope, but they > really are one and the same. > > Still, I crave simplicity...would something like this idea represent > feature bloat in the framework? Is it a stretch to imagine a case in > which you might want not a hardcoded list of args from the event but > rather a list specified programmatically (I.e., > event.getArgs(myArgList))....I dunno,thinking out loud at this point.. > > Joe > > > > On 2/11/11, Peter J. Farrell <[email protected]> wrote: >> No idea is dumb... Actually, I never really thought about this because I >> don't usually pass structs around because I either use call-method >> (1.8+) or pass in individual arguments. That being said... it is an >> interesting idea. >> >> It's bit close to our Utils copyToScope() which offers a bit more >> functionality. >> >> <cfset var argsToPass = StructNew() /> >> >> <cfset >> getUtils().copyToScope("${event.firstName:''},${levent.lastName},squirrelZipper=${event.oakTree},someProperty=${properties.someValue}", >> argsToPass) /> >> >> CopyToScope() offers a couple additional features: >> >> * Assign results to a different key - squirrelZipper=${event.oakTree} >> * Allowing you to set defaults - ${event.firstName:''} sets a default >> value of "" (zero-length string) >> * Assignments from properties in addition to event-args >> * Deep diving via ${event.person.firstName} calls getFirstName() from >> the person bean >> >> Does that work for you? I know it's slightly more typing due to the M2 >> EL syntax. All the things the CopyToScope() is in the documentation >> include more complex cases: >> >> http://trac.mach-ii.com/machii/wiki/UsingCopyToScope >> >> Let's keep discussing it. >> >> .Peter >> >> Joe Bodell said the following on 02/11/2011 02:24 PM: >>> All, >>> >>> Apologies in advance if this has been hashed out and deemed a dumb >>> idea. That being said.... >>> >>> machii.framework.event's getArgs() method currently just returns the >>> variables.args structure. I've run into more than a few cases where I >>> need to grab out several -- but not *all* -- of the event args, but >>> end up having to do something like this: >>> >>> <cfset var argsToPass = structNew() >>> >>> <cfset argsToPass.firstArg = event.getArg("firstArgName") /> >>> <cfset argsToPass.secondArg = event.getArg("secondArgName") /> >>> <cfset argsToPass.thirdArg = event.getArg("thirdArgName") /> >>> <cfset argsToPass.randomArg = event.getArg("randomArgThing") /> >>> <cfset argsToPass.SquirrelZipper = event.getArg("OakTree") /> >>> >>> Et cetera. Would it make sense to add an optional argument to the >>> getArgs() method to specify a list of arguments to send back, like so: >>> <cffunction name="getArgs" access="public" returntype="struct" >>> output="false" >>> hint="Returns all args in this event."> >>> <cfargument name="argList" type="string" required="no" >>> default="" /> >>> >>> <cfset var returnArgs = structNew() /> >>> >>> <cfif arguments.argList EQ ""> >>> <cfreturn variables.args /> >>> <cfelse> >>> <cfloop list="#arguments.argList#" index="currentArg"> >>> <cfif structKeyExists(variables.args, currentArg)> >>> <cfset returnArgs[currentArg] = >>> variables.args[currentArg] /> >>> <cfelse> >>> <cfset returnArgs[currentArg] = "" /> >>> </cfif> >>> </cfloop> >>> >>> <cfreturn returnArgs /> >>> </cfif> >>> </cffunction> >>> >>> This way, my original block of code becomes... >>> >>> <cfset argsToPass = event.getArgs("firstArg,secondArg,thirdArg....") /> >>> >>> and the effect is cleaner-looking code with the same functionality. >>> >>> Thoughts? >>> >>> Thanks, >>> >>> Joe >>> -- >>> Come see Team Mach-II at OpenCFSummit - Feb 21-23, Dallas, TX - >>> http://www.opencfsummit.org/ >>> >>> To post to this group, send email to >>> [email protected] >>> For more options and to unsubscribe, visit this group at >>> http://groups.google.com/group/mach-ii-for-coldfusion?hl=en >>> >>> SVN: http://svn.mach-ii.com/machii/ >>> Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/ >> >> -- >> Come see Team Mach-II at OpenCFSummit - Feb 21-23, Dallas, TX - >> http://www.opencfsummit.org/ >> >> To post to this group, send email to [email protected] >> For more options and to unsubscribe, visit this group at >> http://groups.google.com/group/mach-ii-for-coldfusion?hl=en >> >> SVN: http://svn.mach-ii.com/machii/ >> Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/ >> > > > -- > ------------------------ > Joe Bodell > [email protected] > (c) 952-465-5096 > > -- > Come see Team Mach-II at OpenCFSummit - Feb 21-23, Dallas, TX - > http://www.opencfsummit.org/ > > To post to this group, send email to [email protected] > For more options and to unsubscribe, visit this group at > http://groups.google.com/group/mach-ii-for-coldfusion?hl=en > > SVN: http://svn.mach-ii.com/machii/ > Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/ > -- Come see Team Mach-II at OpenCFSummit - Feb 21-23, Dallas, TX - http://www.opencfsummit.org/ To post to this group, send email to [email protected] For more options and to unsubscribe, visit this group at http://groups.google.com/group/mach-ii-for-coldfusion?hl=en SVN: http://svn.mach-ii.com/machii/ Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/
