You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Eduardo Godoy Vega <eg...@mail.tekchile.cl> on 2001/10/09 18:23:00 UTC
[C2] What am I doing wrong?
Hi...
here is my problem ... I can't pass parameter from Action to XSP ...
Here goes my code ...
this is my sitemap (a part of)
<map:components>
...
<map:actions>
<map:action name="unveil-it" src="com.unveil.taglib.cocoon.UnveilAction"/>
</map:actions>
...
</map:components>
<map:pipelines>
...
<map:match pattern="process-unveil">
<map:act type="unveil-it" >
<map:generate type="serverpages" src="do_unveil.xsp"/>
<map:transform src="stylesheets/llbean-html.xsl"/>
</map:act>
<map:serialize/>
</map:match>
...
</map:pipelines>
my ActionClass is :
public class UnveilAction extends AbstractAction {
private static java.lang.String UNVEIL_INPUT_FIELD = "Question";
public Map act (Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters params) {
Request request = (Request) objectModel.get (Constants.REQUEST_OBJECT);
if (request == null){
getLogger().debug ("UnveilAction: no request object");
return null;
}
HashMap sitemapParams = new HashMap();
String sQuestion = request.getParameter(UNVEIL_INPUT_FIELD);
if (sQuestion == null){
getLogger().debug ("UnveilAction: Question is null");
return null;
}
sitemapParams.put("result","From Action:"+sQuestion);
request.setAttribute("unveil_result","From Action:"+sQuestion);
return sitemapParams;
}
and my do_unveil.xsp:
<xsp:page languaje="java" xmlns:xsp="http://apache.org/xsp"
xmlns:log="http://apache.org/xsp/log/2.0"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<page>
<help>
<para>GET: <xsp-request:get-parameter name="unveil_result"/>.</para>
</help>
</page>
</xsp:page>
BUT unveil_result is always NULL !!
---------------------------------------------------------------------
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] What am I doing wrong?
Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Hi!
The problem is that you put your param into the request attributes and try
to get it from request parameters. They are not the same.
Try this:
<para>GET: <xsp-request:get-attribute name="unveil_result"/>.</para>
and I hope it will work. Another solution is to use the sitemap and pass
params to xsp generator. See other replies to your question.
Regards,
Konstantin Piroumian
> Hi...
> here is my problem ... I can't pass parameter from Action to XSP ...
>
> Here goes my code ...
>
> this is my sitemap (a part of)
> <map:components>
> ...
> <map:actions>
> <map:action name="unveil-it"
src="com.unveil.taglib.cocoon.UnveilAction"/>
> </map:actions>
> ...
> </map:components>
>
> <map:pipelines>
> ...
> <map:match pattern="process-unveil">
> <map:act type="unveil-it" >
> <map:generate type="serverpages" src="do_unveil.xsp"/>
> <map:transform src="stylesheets/llbean-html.xsl"/>
> </map:act>
> <map:serialize/>
> </map:match>
>
> ...
> </map:pipelines>
>
> my ActionClass is :
>
> public class UnveilAction extends AbstractAction {
> private static java.lang.String UNVEIL_INPUT_FIELD = "Question";
>
> public Map act (Redirector redirector,
> SourceResolver resolver,
> Map objectModel,
> String source,
> Parameters params) {
> Request request = (Request) objectModel.get (Constants.REQUEST_OBJECT);
> if (request == null){
> getLogger().debug ("UnveilAction: no request object");
> return null;
> }
> HashMap sitemapParams = new HashMap();
> String sQuestion = request.getParameter(UNVEIL_INPUT_FIELD);
> if (sQuestion == null){
> getLogger().debug ("UnveilAction: Question is null");
> return null;
> }
> sitemapParams.put("result","From Action:"+sQuestion);
> request.setAttribute("unveil_result","From Action:"+sQuestion);
> return sitemapParams;
> }
>
> and my do_unveil.xsp:
> <xsp:page languaje="java" xmlns:xsp="http://apache.org/xsp"
> xmlns:log="http://apache.org/xsp/log/2.0"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0">
> <page>
> <help>
> <para>GET: <xsp-request:get-parameter name="unveil_result"/>.</para>
> </help>
> </page>
> </xsp:page>
>
> BUT unveil_result is always NULL !!
>
>
> ---------------------------------------------------------------------
> 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>
>
---------------------------------------------------------------------
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>
[C2] What am I doing wrong? (action -> xsp parameter passing)
Posted by Gregory Steuck <gr...@buildpoint.com>.
Eduardo,
Here's how I managed to pass parameters from an action to an xsp page:
sitemap:
<map:act type="project-available">
<map:generate src="docs/project_extract.xsp">
<map:parameter name="xsp_pid" value="{pid}"/>
</map:generate>
action:
public Map act (Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters params) {
Map sitemapParams = new HashMap();
sitemapParams.put("pid", projectIdString);
return sitemapParams;
}
xsp:
<xsp:expr>parameters.getParameter("xsp_pid","BUG_IN_SITEMAP")</xsp:expr>
Hope it helps.
Thanks
Greg
---------------------------------------------------------------------
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] What am I doing wrong?
Posted by Tobias Luikard <t....@exxcellent.de>.
Hi Eduardo,
The thing I had to learn myselve (It has driven me crazy too):
Don't put an Attribute
> request.setAttribute("unveil_result","From Action:"+sQuestion);
and the expect a parameter to receive
> <para>GET: <xsp-request:get-parameter name="unveil_result"/>.</para>
try this:
<para>GET: <xsp-request:get-attribute name="unveil_result"/>.</para>
Hope this helps.
By
Tobias
--
Tobias Luikard
____ |X________________________
X|
eXXcellent solutions gmbh
In der Wanne 55
D-89075 Ulm
e | T.Luikard@eXXcellent.de
t | +49 [0]731-55026-22
f | +49 [0]731-55026-99
i | www.eXXcellent.de
---------------------------------------------------------------------
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>