You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Bentley, Tim" <TI...@ca.com> on 2001/05/18 07:53:25 UTC
[C2] Question - passing parameters to a generator
I had thought that it was possible to pass parameters to an xsp page from
the sitemap like this:
<map:match pattern="apage.xml">
<map:generate type="serverpages" src="timtest/dealwithapage.xml">
<parameter name="myparam" value="paramvalue"/>
</map:generate>
<map:serialize/>
</map:match>
I am trying to access the parameter in the page using
<xsp-request:get-parameter>, but it's not coming through. Shoudl this be
possible, and if so, an someone tell me what am I doing wrong?
Thanks!
Tim Bentley
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] Question - passing parameters to a generator
Posted by Sylvain Wallez <sy...@anyware-tech.com>.
"Bentley, Tim" a écrit :
>
> I had thought that it was possible to pass parameters to an xsp page from
> the sitemap like this:
>
> <map:match pattern="apage.xml">
> <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> <parameter name="myparam" value="paramvalue"/>
> </map:generate>
> <map:serialize/>
> </map:match>
>
> I am trying to access the parameter in the page using
> <xsp-request:get-parameter>, but it's not coming through. Shoudl this be
> possible, and if so, an someone tell me what am I doing wrong?
>
> Thanks!
>
> Tim Bentley
>
As its name implies, xsp-request:get-parameter fetches *request*
parameters, i.e. those of the HTTP request.
To access parameters passed by the sitemap, use
<xsp:expr>parameters.getParameter("myparam", "defaultValue")</xsp:expr>
--
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] Question - passing parameters to a generator
Posted by giacomo <gi...@apache.org>.
On Fri, 18 May 2001, Bentley, Tim wrote:
> I had thought that it was possible to pass parameters to an xsp page from
> the sitemap like this:
>
> <map:match pattern="apage.xml">
> <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> <parameter name="myparam" value="paramvalue"/>
> </map:generate>
> <map:serialize/>
> </map:match>
>
> I am trying to access the parameter in the page using
> <xsp-request:get-parameter>, but it's not coming through. Shoudl this be
> possible, and if so, an someone tell me what am I doing wrong?
You are trying to access the http request parameters which are passed
into C2 from the client (browser). The parameters you've specified in
your sample above will be accessed by your xsp page with:
<xsp:expr> parameters.getparameter("myparam")</xsp:expr>
there is no logicsheet available yet to access them in a way like the
parameters from the request object.
Giacomo
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] Question - passing parameters to a generator
Posted by Torsten Curdt <tc...@dff.st>.
> > > I had thought that it was possible to pass parameters to an xsp page from
> > > the sitemap like this:
> > >
> > > <map:match pattern="apage.xml">
> > > <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> > > <parameter name="myparam" value="paramvalue"/>
> > > </map:generate>
> > > <map:serialize/>
> > > </map:match>
> > >
> > > I am trying to access the parameter in the page using
> > > <xsp-request:get-parameter>, but it's not coming through. Shoudl this be
> > > possible, and if so, an someone tell me what am I doing wrong?
> >
> > Do you want to access it within a logicsheet as XSLT variable or
> > as java object in your XSP page? (Looks like you want an object)
> >
> > I had a look at this, too. The parameters are not yet passed to
> > the code generating transformer. So a big "no" for the first one.
> > (But I think this should become a "yes" for consistency reasons)
> >
>
> The aren't passed to the code generating transformer because their value
> may change for each request, and so passing them to logicsheets would
> require to regenerate and recompile XSP code for each request.
As I posted before in cocoon-dev... That's not always true!!
[from the post]
>I think there is just one rule: if you pass a substituted sitemap
>parameter the substitution must appear in the src attribute as well.
>This will make the generated code distinct by the parameter.
>I just think it is stupid to parse the URI in the serverpage
>on every request if you already have everything at your finger
>tips at compile time.
Look at this example:
<map:match pattern="apage.*">
<map:generate type="serverpages" src="timtest/{1}/dealwithapage.xsp">
<parameter name="myparam" value="{1}"/>
</map:generate>
<map:serialize/>
</map:match>
</map:match>
This should NOT force a recompilation for every request! The created
generator are distinct because of the variable being in the src
attribute.
Of course you create really stupid sitemaps using it the wrong
way. But for consistency I think we should have it...
See now what I mean? ;)
--
Torsten
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] Question - passing parameters to a generator
Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Torsten Curdt a écrit :
>
> On Fri, 18 May 2001, Bentley, Tim wrote:
>
> > I had thought that it was possible to pass parameters to an xsp page from
> > the sitemap like this:
> >
> > <map:match pattern="apage.xml">
> > <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> > <parameter name="myparam" value="paramvalue"/>
> > </map:generate>
> > <map:serialize/>
> > </map:match>
> >
> > I am trying to access the parameter in the page using
> > <xsp-request:get-parameter>, but it's not coming through. Shoudl this be
> > possible, and if so, an someone tell me what am I doing wrong?
>
> Do you want to access it within a logicsheet as XSLT variable or
> as java object in your XSP page? (Looks like you want an object)
>
> I had a look at this, too. The parameters are not yet passed to
> the code generating transformer. So a big "no" for the first one.
> (But I think this should become a "yes" for consistency reasons)
>
The aren't passed to the code generating transformer because their value
may change for each request, and so passing them to logicsheets would
require to regenerate and recompile XSP code for each request.
> The second one should work....
>
> Did you have a look at the compiled sitemap?
>
> You might want to try this as a work around:
>
> <map:match pattern="apage.xml">
> <map:act set="action">
> <parameter name="myparam" value="paramvalue"/>
> <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> </map:act>
> <map:serialize type="xml"/>
> </map:match>
>
> This is how I use it...
>
> Hope this helps
> --
> Torsten
>
Tim's sitemap snippet is OK : sitemap parameters are accessible in XSP
with "parameters.getParameter()" (see my previous post)
--
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] Question - passing parameters to a generator
Posted by Torsten Curdt <tc...@dff.st>.
On Fri, 18 May 2001, Bentley, Tim wrote:
> I had thought that it was possible to pass parameters to an xsp page from
> the sitemap like this:
>
> <map:match pattern="apage.xml">
> <map:generate type="serverpages" src="timtest/dealwithapage.xml">
> <parameter name="myparam" value="paramvalue"/>
> </map:generate>
> <map:serialize/>
> </map:match>
>
> I am trying to access the parameter in the page using
> <xsp-request:get-parameter>, but it's not coming through. Shoudl this be
> possible, and if so, an someone tell me what am I doing wrong?
Do you want to access it within a logicsheet as XSLT variable or
as java object in your XSP page? (Looks like you want an object)
I had a look at this, too. The parameters are not yet passed to
the code generating transformer. So a big "no" for the first one.
(But I think this should become a "yes" for consistency reasons)
The second one should work....
Did you have a look at the compiled sitemap?
You might want to try this as a work around:
<map:match pattern="apage.xml">
<map:act set="action">
<parameter name="myparam" value="paramvalue"/>
<map:generate type="serverpages" src="timtest/dealwithapage.xml">
</map:act>
<map:serialize type="xml"/>
</map:match>
This is how I use it...
Hope this helps
--
Torsten
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>