You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Collin VanDyck <cv...@mindspring.com> on 2003/02/12 22:44:19 UTC
Pass custom parameters into an XSP
Hello,
I am trying to figure out how I can pass in custom parameters into an already existing generator such as the XSP/serverpages generator. Here's my scenario:
I receive a request for /edit/page
Which matches /edit/*
So from this matcher, I have {1} == "page".. I want to pass this off to let's say
/docs/xsp/edit/item.xsp as a parameter named "entityType"
So that in the XSP I can access the "entityType" variable.
I think I'm missing something obvious. If someone could point me into the right direction, I'd really appreciate it.
thanks,
Collin
Re: Pass custom parameters into an XSP
Posted by Collin VanDyck <cv...@mindspring.com>.
Wow. I did not know you could use the XSP to override the setup method. That is VERY helpful. Thanks!!
----- Original Message -----
From: Marco Rolappe
To: cocoon-users@xml.apache.org
Sent: Wednesday, February 12, 2003 5:59 PM
Subject: AW: Pass custom parameters into an XSP
hi collin,
with XSPs an easier alternative would be to pass your 'parameter' as a request parameter.
then you would:
<map:match pattern="edit.xml">
<map:generate type="serverpages" src="/docs/edit/item.xsp"/>
<map:serialize type="xml"/>
</map:match>
<map:match pattern="edit/*">
<map:generate src="cocoon:/edit.xml?entityType={1}"/>
...
</map:match>
then you can get the request parameter from within your XSP via the request logicsheet (<xsp-request:get-parameter>) or via embedded logic (request.getParameter ()).
the other alternative; passing the parameter as a sitemap parameter:
<map:match pattern="edit/*">
<map:generate type="serverpages" src="/docs/edit/item.xsp">
<map:parameter name="entityType" value="{1}"/>
</map:generate>
...
</map:match>
for this to work you have to embed the appropriate logic into your XSP for retrieving that parameter; as your compiled XSP is a generator in the end you accomplish this by overriding its setup() method and process the parameter(s) there.
just as a hint (take a look at the respective sources/docs):
<xsp:page language="java" ...>
<xsp:logic> <!-- must occur before content so that it doesn't become part of content/generate() method -->
public void setup (SourceResolver resolver, Map objectModel, String src, Parameters params) throws ...
{
// process parameter(s) here
...
super.setup (resolver, objectModel, src, params);
}
</xsp:logic>
<!-- content here -->
</xsp:page>
HTH
-----Ursprüngliche Nachricht-----
Von: cocoon-users-return-46552-m_rolappe=web.de@xml.apache.org [mailto:cocoon-users-return-46552-m_rolappe=web.de@xml.apache.org]Im Auftrag von Collin VanDyck
Gesendet: Mittwoch, 12. Februar 2003 22:44
An: cocoon-users@xml.apache.org
Betreff: Pass custom parameters into an XSP
Hello,
I am trying to figure out how I can pass in custom parameters into an already existing generator such as the XSP/serverpages generator. Here's my scenario:
I receive a request for /edit/page
Which matches /edit/*
So from this matcher, I have {1} == "page".. I want to pass this off to let's say
/docs/xsp/edit/item.xsp as a parameter named "entityType"
So that in the XSP I can access the "entityType" variable.
I think I'm missing something obvious. If someone could point me into the right direction, I'd really appreciate it.
thanks,
Collin
AW: Pass custom parameters into an XSP
Posted by Marco Rolappe <m_...@web.de>.
hi collin,
with XSPs an easier alternative would be to pass your 'parameter' as a
request parameter.
then you would:
<map:match pattern="edit.xml">
<map:generate type="serverpages" src="/docs/edit/item.xsp"/>
<map:serialize type="xml"/>
</map:match>
<map:match pattern="edit/*">
<map:generate src="cocoon:/edit.xml?entityType={1}"/>
...
</map:match>
then you can get the request parameter from within your XSP via the request
logicsheet (<xsp-request:get-parameter>) or via embedded logic
(request.getParameter ()).
the other alternative; passing the parameter as a sitemap parameter:
<map:match pattern="edit/*">
<map:generate type="serverpages" src="/docs/edit/item.xsp">
<map:parameter name="entityType" value="{1}"/>
</map:generate>
...
</map:match>
for this to work you have to embed the appropriate logic into your XSP for
retrieving that parameter; as your compiled XSP is a generator in the end
you accomplish this by overriding its setup() method and process the
parameter(s) there.
just as a hint (take a look at the respective sources/docs):
<xsp:page language="java" ...>
<xsp:logic> <!-- must occur before content so that it doesn't become part
of content/generate() method -->
public void setup (SourceResolver resolver, Map objectModel, String src,
Parameters params) throws ...
{
// process parameter(s) here
...
super.setup (resolver, objectModel, src, params);
}
</xsp:logic>
<!-- content here -->
</xsp:page>
HTH
-----Ursprüngliche Nachricht-----
Von: cocoon-users-return-46552-m_rolappe=web.de@xml.apache.org
[mailto:cocoon-users-return-46552-m_rolappe=web.de@xml.apache.org]Im Auftrag
von Collin VanDyck
Gesendet: Mittwoch, 12. Februar 2003 22:44
An: cocoon-users@xml.apache.org
Betreff: Pass custom parameters into an XSP
Hello,
I am trying to figure out how I can pass in custom parameters into an
already existing generator such as the XSP/serverpages generator. Here's my
scenario:
I receive a request for /edit/page
Which matches /edit/*
So from this matcher, I have {1} == "page".. I want to pass this off to
let's say
/docs/xsp/edit/item.xsp as a parameter named "entityType"
So that in the XSP I can access the "entityType" variable.
I think I'm missing something obvious. If someone could point me into the
right direction, I'd really appreciate it.
thanks,
Collin