Kirk Brogdon wrote:

I'm working on a Mach-ii application but I think this is more of a cfscript
question so I'm posting it here.  I have a filter that I am trying to set up
so that I can pass it the name of getter method through the event arguments
and then execute it - the problem I am having is that it simply sees the
variable as a string and doesn't execute it.  If I was using cfml I could
build the string and pound it to get the value but I don't know how to do
that in cfscript (or if it's possible).  I can probably set up a switch
statement to cover what I need but I was hoping to make the filter dynamic
enough that I could just pass it the object name and the method and go from
there.

This works:
                <cfscript>
                        var ObjectName = "";
                        var invalidEvent = "";
                        var clearEventQueue = false;

                        . . .

                        if ( arguments.event.getArg( objectName ).getSb_Id() 
neq '' ) {
                                return true;    // allow processing to continue
                        } else {
                                if ( clearEventQueue ) {
                                        
arguments.eventContext.clearEventQueue();
                                }
                        . . .

But if I try to pass in the getSb_Id() as an argument then it gets upset:

                <cfscript>
                        var ObjectName = "";
                        var invalidEvent = "";
                        var clearEventQueue = false;
                        var getter = "";

                        . . .


                        if ( structKeyExists( arguments.paramArgs, "getter"  ) )
                        {
                                getter = arguments.paramArgs.getter;
                        } else
                        {
                                getter = getParameter( "getter", "" );
                        . . .

                        if ( arguments.event.getArg( objectName ).getter neq '' 
) {
                                return true;    // allow processing to continue
                        } else {



Any ideas?


Thanks - Kirk
I don't think it's possible to dynamically set the method you want to call in cfscript...IIRC. You'll have to rely on cfinvoke to do it for you. If you want to use cfscript, you might consider creating a private function in you filter that you can pass the method name in, cfinvoke the method you want and return the data. You could also insert some error handling as well incase the method doesn't exists - might be help during development.

Best,
.Peter

--
Peter J. Farrell :: Maestro Publishing

blog    :: http://blog.maestropublishing.com
email   :: [EMAIL PROTECTED]

Create boilerplate beans!
Check out the Mach-II Bean Creator - free download.
http://blog.maestropublishing.com/mach-ii_beaner.htm


"Bread doesn't make people fat - people make people fat."
Garisson Keillor - A Prairie Home Companion

--


----------------------------------------------------------
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).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to