You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Paul Joseph <pj...@gmail.com> on 2012/01/03 15:19:06 UTC
how do I specify function parameters in the URL
Hi there,
I know that I can call a function with parameters using the sitemap as
for ex.:
<map:flow language="javascript">
<map:script src="myApplication.js"/>
</map:flow>
<map:pipelines>
<map:pipeline>
<map:match pattern="index.html">
<map:call function="showIndexPage">
<map:parameter name="paramName" value="Value"/>
</map:call>
</map:match>
</map:pipeline>
</map:pipelines>
and:
Then in myApplication.js you would define a JavaScript function called
showIndexPage() such as:
function showIndexPage() { var param = cocoon.parameters.paramName;
sendPage("private/index.html", {param: param}); }
But how would I use this to call a function whose arguments are in the
calling URL.
Ex. say I wanted to login any user where the user's name is specified in
the URLhow could I do this? For example if I wanted to call a function
using the user's login name that I specify in the URL (say the user is
jsmith), and I used a URL as below, how would I pass on jsmith on to the
flowscript?:
Ex.: http://myserver:8080/myApp/login/jsmith
thx.
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: how do I specify function parameters in the URL
Posted by Paul Joseph <pj...@gmail.com>.
Ah...yes, got it, thanks!
Paul
On 1/3/2012 9:25 AM, Robby Pelssers wrote:
> Not sure if your setup is working like the sample below, but you can easily pass a parameter which you extract from the URI or just pass a request parameter
>
> Example 1:
> <map:match pattern="login/*">
> <map:call function="showIndexPage">
> <map:parameter name="paramName" value="{1}"/>
> </map:call>
> </map:match>
>
>
> Example 2:
>
> <map:match pattern="login.html">
> <map:call function="showIndexPage">
> <map:parameter name="paramName" value="{request-param:userId}"/>
> </map:call>
> </map:match>
>
>
> Kind regards,
> Robby
>
> -----Original Message-----
> From: Paul Joseph [mailto:pjoseph@gmail.com]
> Sent: Tuesday, January 03, 2012 3:19 PM
> To: users@cocoon.apache.org
> Subject: how do I specify function parameters in the URL
>
> Hi there,
>
> I know that I can call a function with parameters using the sitemap as
> for ex.:
>
> <map:flow language="javascript">
> <map:script src="myApplication.js"/>
> </map:flow>
> <map:pipelines>
> <map:pipeline>
> <map:match pattern="index.html">
> <map:call function="showIndexPage">
> <map:parameter name="paramName" value="Value"/>
> </map:call>
> </map:match>
> </map:pipeline>
> </map:pipelines>
>
> and:
>
> Then in myApplication.js you would define a JavaScript function called
> showIndexPage() such as:
>
> function showIndexPage() { var param = cocoon.parameters.paramName;
> sendPage("private/index.html", {param: param}); }
>
>
>
> But how would I use this to call a function whose arguments are in the
> calling URL.
>
> Ex. say I wanted to login any user where the user's name is specified in
> the URLhow could I do this? For example if I wanted to call a function
> using the user's login name that I specify in the URL (say the user is
> jsmith), and I used a URL as below, how would I pass on jsmith on to the
> flowscript?:
>
> Ex.: http://myserver:8080/myApp/login/jsmith
>
> thx.
> Paul
>
>
>
> ---------------------------------------------------------------------
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: how do I specify function parameters in the URL
Posted by Robby Pelssers <Ro...@nxp.com>.
Not sure if your setup is working like the sample below, but you can easily pass a parameter which you extract from the URI or just pass a request parameter
Example 1:
<map:match pattern="login/*">
<map:call function="showIndexPage">
<map:parameter name="paramName" value="{1}"/>
</map:call>
</map:match>
Example 2:
<map:match pattern="login.html">
<map:call function="showIndexPage">
<map:parameter name="paramName" value="{request-param:userId}"/>
</map:call>
</map:match>
Kind regards,
Robby
-----Original Message-----
From: Paul Joseph [mailto:pjoseph@gmail.com]
Sent: Tuesday, January 03, 2012 3:19 PM
To: users@cocoon.apache.org
Subject: how do I specify function parameters in the URL
Hi there,
I know that I can call a function with parameters using the sitemap as
for ex.:
<map:flow language="javascript">
<map:script src="myApplication.js"/>
</map:flow>
<map:pipelines>
<map:pipeline>
<map:match pattern="index.html">
<map:call function="showIndexPage">
<map:parameter name="paramName" value="Value"/>
</map:call>
</map:match>
</map:pipeline>
</map:pipelines>
and:
Then in myApplication.js you would define a JavaScript function called
showIndexPage() such as:
function showIndexPage() { var param = cocoon.parameters.paramName;
sendPage("private/index.html", {param: param}); }
But how would I use this to call a function whose arguments are in the
calling URL.
Ex. say I wanted to login any user where the user's name is specified in
the URLhow could I do this? For example if I wanted to call a function
using the user's login name that I specify in the URL (say the user is
jsmith), and I used a URL as below, how would I pass on jsmith on to the
flowscript?:
Ex.: http://myserver:8080/myApp/login/jsmith
thx.
Paul
---------------------------------------------------------------------
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
Re: how do I specify function parameters in the URL
Posted by Paul Joseph <pj...@gmail.com>.
Thanks Thorsten, appreciate it!
Paul
On 1/3/2012 1:22 PM, Thorsten Scherler wrote:
> On Tue, 2012-01-03 at 09:19 -0500, Paul Joseph wrote:
>> Hi there,
>>
>> I know that I can call a function with parameters using the sitemap as
>> for ex.:
>>
>> <map:flow language="javascript">
>> <map:script src="myApplication.js"/>
>> </map:flow>
>> <map:pipelines>
>> <map:pipeline>
>> <map:match pattern="index.html">
>> <map:call function="showIndexPage">
>> <map:parameter name="paramName" value="Value"/>
>> </map:call>
>> </map:match>
>> </map:pipeline>
>> </map:pipelines>
>>
>> and:
>>
>> Then in myApplication.js you would define a JavaScript function called
>> showIndexPage() such as:
>>
>> function showIndexPage() { var param = cocoon.parameters.paramName;
>> sendPage("private/index.html", {param: param}); }
>>
>>
>>
>> But how would I use this to call a function whose arguments are in the
>> calling URL.
>>
>> Ex. say I wanted to login any user where the user's name is specified in
>> the URLhow could I do this? For example if I wanted to call a function
>> using the user's login name that I specify in the URL (say the user is
>> jsmith), and I used a URL as below, how would I pass on jsmith on to the
>> flowscript?:
>>
>> Ex.: http://myserver:8080/myApp/login/jsmith
> Depends a bit on your version of cocoon but the following will work in
> all version (replace {1} with {map:1} for c3).
>
> <map:flow language="javascript">
> <map:script src="myApplication.js"/>
> </map:flow>
> <map:pipelines>
> <map:pipeline>
> <map:match pattern="index.html">
> <map:call function="showIndexPage">
> <map:parameter name="paramName" value="Value"/>
> </map:call>
> </map:match>
> <map:match pattern="login/*">
> <map:call function="login">
> <map:parameter name="user" value="{1}"/>
> </map:call>
> </map:match>
> </map:pipeline>
> </map:pipelines>
>
> HTH
>
> salu2
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: how do I specify function parameters in the URL
Posted by Thorsten Scherler <sc...@gmail.com>.
On Tue, 2012-01-03 at 09:19 -0500, Paul Joseph wrote:
> Hi there,
>
> I know that I can call a function with parameters using the sitemap as
> for ex.:
>
> <map:flow language="javascript">
> <map:script src="myApplication.js"/>
> </map:flow>
> <map:pipelines>
> <map:pipeline>
> <map:match pattern="index.html">
> <map:call function="showIndexPage">
> <map:parameter name="paramName" value="Value"/>
> </map:call>
> </map:match>
> </map:pipeline>
> </map:pipelines>
>
> and:
>
> Then in myApplication.js you would define a JavaScript function called
> showIndexPage() such as:
>
> function showIndexPage() { var param = cocoon.parameters.paramName;
> sendPage("private/index.html", {param: param}); }
>
>
>
> But how would I use this to call a function whose arguments are in the
> calling URL.
>
> Ex. say I wanted to login any user where the user's name is specified in
> the URLhow could I do this? For example if I wanted to call a function
> using the user's login name that I specify in the URL (say the user is
> jsmith), and I used a URL as below, how would I pass on jsmith on to the
> flowscript?:
>
> Ex.: http://myserver:8080/myApp/login/jsmith
Depends a bit on your version of cocoon but the following will work in
all version (replace {1} with {map:1} for c3).
<map:flow language="javascript">
<map:script src="myApplication.js"/>
</map:flow>
<map:pipelines>
<map:pipeline>
<map:match pattern="index.html">
<map:call function="showIndexPage">
<map:parameter name="paramName" value="Value"/>
</map:call>
</map:match>
<map:match pattern="login/*">
<map:call function="login">
<map:parameter name="user" value="{1}"/>
</map:call>
</map:match>
</map:pipeline>
</map:pipelines>
HTH
salu2
--
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org