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/