cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira>
Subject Re: Understanding/extending the PetStore example
Date Wed, 02 Nov 2005 13:23:12 GMT
Derek Hohls wrote:
> I am trying to get a handle on a key function in the PetStore example;
> the sitemap handles a call to any function in the sample as follows:
>       <map:match pattern="*.do">
>         <map:call function="main">
>           <map:parameter name="page" value="{1}"/>
>         </map:call>
>       </map:match>
> in the petstore.js code, there is the corresponding match:
> function main(funName) {
>     var fun = this[funName];
>     ...
> }

That method of defining parameters for flowscript functions relies upon
the order of the parameters within the sitemap, and has therefore been
deprecated. You are recommended to use the cocoon.parameters approach
instead. However, all you are doing, in effect, is setting funName to
whatever {1} was.

> when I use the Rhino JavaScript debugger, it shows clearly
> that the value of "funName" in the main(funName) is that of
> the function being called.  However, it is not clear as to where/
> how that value becomes associated with the function parameter.
> In my application, where I try the same type of code, I end up
> with a null value for "funName"... but I cannot see where/how 
> to get the right value in there.

So, funName is the name of a function. As functions are defined within
the current scope (this), this[funName] gets you the function with that
name. Note, it doesn't execute it. You can now execute that function
with fun(), or fun(some, set, of, parameters);

> Any help would be appreciated.

Does that help?

Regards, Upayavira

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message