You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Leona Slepetis <le...@gorillacommunications.com> on 2002/07/09 22:13:24 UTC
trouble getting return values from an Action Map
Hi All,
I've gone through the samples and archives and still am having trouble
getting return values from an Action.
I followed the sample code for a simple action:
public class GSLoginAction extends AbstractAction {
public Map act (Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters params) {
String strUserID;
String strPwd;
String strPlayerID = "";
Request request = ObjectModelHelper.getRequest(objectModel);
strUserID = request.getParameter("userID");
strPwd = request.getParameter("pwd");
// do something with the request parameters here and set strPlayerID
sitemapParams.put("playerID", strPlayerID);
request.setAttribute("playerID", strPlayerID);
if (// the right thing happened) {
return sitemapParams;
}else {
return(null);
}
}
It is defined in the sitemap under <map:actions>, pointing to the correct
class file.
The action is called from this pipeline fragment, which is attached to
the "ACTION" button of a form with two text boxes, "userID" and "pwd".
<map:match pattern="login">
<map:act type="gs-login">
<map:parameter name="use-request-parameters" value="true"/>
<map:parameter name="userID" value="{1}"/>
<map:parameter name="pwd" value="{2}"/>
<map:redirect-to uri="summary">
<map:parameter name="playerID" value="{playerID}"/>
</map:redirect-to>
</map:act>
<map:redirect-to uri="gs"/>
</map:match>
I know that the action is running, and the parameters are passed in, because
of some debugging I did in the Java code. I seem to be getting something
back, becuase if I enter correct values on the form, redirect
to "summary" does happen. Otherwise it goes to "gs".
<map:match pattern="summary">
<map:generate src="gs.xml"/>
<map:transform src="gs.xsl">
<map:parameter name="use-request-parameters" value="true"/>
<map:parameter name="pagename" value="summary"/>
<map:parameter name="playerID" value="{1}"/>
</map:transform>
<map:transform src="default-html.xsl"/>
<map:serialize type="html"/>
</map:match>
The problem is that "playedID" is not being passed to "summary". Do I
simply have a syntax error in working with the parameter, or is it more
complicated than
that?
Thanks very much,
Leona
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: trouble getting return values from an Action Map
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 09.Jul.2002 -- 03:13 PM, Leona Slepetis wrote:
> Hi All,
>
> I've gone through the samples and archives and still am having trouble
> getting return values from an Action.
>
> <map:act type="gs-login">
> <map:redirect-to uri="summary">
> <map:parameter name="playerID" value="{playerID}"/>
> <map:match pattern="summary">
> <map:parameter name="playerID" value="{1}"/>
Leona,
I've deleted all but the relevant lines. Since you send a redirect
response to the browser, processing ends.
The browser requests a new page. For this (second) request, no action
is run, thus no values are set.
client cocoon
---------gs-login----->
(action)
<---redirect-to-summary
--------summary------->
<-------summary--------
If you need to keep the value, you could
a) use cocoon: protocol in a generator
b) put summary in a resource and call it
c) store value e.g. in session
Chris.
Please follow up summarizing your problem and which suggested solution
/ information worked for you when you consider your problem
solved. Add "SUMMARY: " to the subject line. This will make FAQ
generation and searching the list easier. In addition, it makes
helping you more fun. Thank you.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: CORREDTION: trouble getting return values from an Action Map
Posted by Leona Slepetis <le...@gorillacommunications.com>.
Yes, I do declare
Map sitemapParams = new HashMap();
in the action.
Sorry for the error.
Leona
> Hi All,
>
> I've gone through the samples and archives and still am having trouble
> getting return values from an Action.
>
> I followed the sample code for a simple action:
>
> public class GSLoginAction extends AbstractAction {
> public Map act (Redirector redirector,
> SourceResolver resolver,
> Map objectModel,
> String source,
> Parameters params) {
>
> String strUserID;
> String strPwd;
> String strPlayerID = "";
> Request request = ObjectModelHelper.getRequest(objectModel);
> strUserID = request.getParameter("userID");
> strPwd = request.getParameter("pwd");
>
> // do something with the request parameters here and set strPlayerID
>
> sitemapParams.put("playerID", strPlayerID);
> request.setAttribute("playerID", strPlayerID);
> if (// the right thing happened) {
> return sitemapParams;
> }else {
> return(null);
> }
> }
>
> It is defined in the sitemap under <map:actions>, pointing to the correct
> class file.
> The action is called from this pipeline fragment, which is attached to
> the "ACTION" button of a form with two text boxes, "userID" and "pwd".
>
> <map:match pattern="login">
> <map:act type="gs-login">
> <map:parameter name="use-request-parameters" value="true"/>
> <map:parameter name="userID" value="{1}"/>
> <map:parameter name="pwd" value="{2}"/>
> <map:redirect-to uri="summary">
> <map:parameter name="playerID" value="{playerID}"/>
> </map:redirect-to>
> </map:act>
> <map:redirect-to uri="gs"/>
> </map:match>
>
> I know that the action is running, and the parameters are passed in,
because
> of some debugging I did in the Java code. I seem to be getting something
> back, becuase if I enter correct values on the form, redirect
> to "summary" does happen. Otherwise it goes to "gs".
>
> <map:match pattern="summary">
> <map:generate src="gs.xml"/>
> <map:transform src="gs.xsl">
> <map:parameter name="use-request-parameters" value="true"/>
> <map:parameter name="pagename" value="summary"/>
> <map:parameter name="playerID" value="{1}"/>
> </map:transform>
> <map:transform src="default-html.xsl"/>
> <map:serialize type="html"/>
> </map:match>
>
> The problem is that "playedID" is not being passed to "summary". Do I
> simply have a syntax error in working with the parameter, or is it more
> complicated than
> that?
>
> Thanks very much,
> Leona
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.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/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>