cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <dho...@csir.co.za>
Subject Re: Understanding/extending the PetStore example
Date Wed, 02 Nov 2005 14:30:11 GMT
Upayavira
 
Great! - the code now picks up the name of the function OK;
but does not seem to actually execute it...  i.e. in:
 
function main(funName) {
  var fun = this[funName];
  var args = new Array(arguments.length -1);
  for (var i = 1; i < arguments.length; i++) {
    args[i-1] = arguments[i];
  }
  getIndDB();
  fun.apply(args);
}

The "fun" variable now contains the name of the
function, which I assume the fun.apply() is meant to 
execute ... but the debugger does not show the trace
moving beyond the end of main() - all that happens is that 
the browser now shows a (nearly) blank page:
 
<HTML><HEAD><HEAD>
<BODY></BODY></HTML>
 
I get the same result regardless of which function
in the Javascript is being called...
 
Thanks
Derek

>>> uv@odoko.co.uk 2005/11/02 03:44:04 PM >>>
Derek Hohls wrote:
> Upayavira
> 
> I do appreciate the detailed explanation. It does help... up
> to a point. I assume that the PetStore example will be rewritten
> in future versions (I am still on 2.15) so it does not rely on this 
> deprecated approach. In that case, I guess I will need to update
> my app accordingly.
> 
> In the meantime, I need to figure how why main() does not 
> receive the name of the function called in *.do . Could it be the 
> fact that it is called inside of a protected match:
> 
> <map:match pattern="*.do">
> <map:act type="auth-protect">
> <map:parameter name="handler" value="myhandler"/> 
> <map:call function="main">
> <map:parameter name="page" value="{1}"/>
> </map:call>
> </map:act>
> <map:redirect-to uri="login"/> 
> </map:match>
> 
> and, if so, how do then access the value.
> 
> Otherwise I cannot figure out *why* funName is null??

You got it precisely. Should be:

<map:match pattern="*.do">
<map:act type="auth-protect">
<map:parameter name="handler" value="myhandler"/>
<map:call function="main">
<map:parameter name="page" value="{../1}"/>
</map:call>
</map:act>
<map:redirect-to uri="login"/>
</map:match>

i.e. {../1} to get at the matcher rather than the action.

Regards, Upayavira

>>>> uv@odoko.co.uk 2005/11/02 03:23:12 PM >>>
> 
> 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: users-unsubscribe@cocoon.apache.org 
> For additional commands, e-mail: users-help@cocoon.apache.org 
> 
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
HelpDesk@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message