You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Haase <Jh...@CQOS.COM> on 2001/02/16 19:42:07 UTC
RE: Conditional choice of action mapping based on html FORM and S
ELECT tag
One way you can do it is to use ActionForward's to direct to another action
instead of a jsp. Define an action to "redirect" your requests like this.
<action path="/planner"
type="planner.PlanAction">
<forward name="showReleases" path="/showReleases.do"/>
<forward name="showTestPlan" path="/showTestPlan.do"/>
</action>
Then define an action for each forward from above.
<action path="/showReleases"
type="planner.ShowReleasesAction">
<forward name="success" path="/ShowReleases.jsp"/>
</action>
<action path="/showTestPlan"
type="planner.ShowTestPlanAction">
<forward name="success" path="/ShowTestPlan.jsp"/>
</action>
Finally, write planner.PlanAction to forward to the correct action based
upon the menu choice.
if(/* User picked ShowReleases */)
return (mapping.findForward("showReleases"));
else if (/* User picked ShowTestPlan */)
return (mapping.findForward("showTestPlan"));
-----Original Message-----
From: Ellen Murray [mailto:nospamlass@yahoo.com]
Sent: Friday, February 16, 2001 10:23 AM
To: struts-user@jakarta.apache.org
Subject: Conditional choice of action mapping based on html FORM and
SELECT tag
Hi,
This is a newbie question. I am creating a web
application where each page contains a pull down
menu of commands (SELECT). I want the users choice
of menu item to invoke the next action object.
Because the FORM tag allows only one action, I
want that to be mapped to multiple actions in the
struts-config.xml file. An example of what I'd
like to do is below.
Does anyone have a solution to this? I really need
your help because I am working without access to
other java or web programers.
Thanks - Ellen
//
// What I want in my web page
//
<FORM ACTION="planner.do" >
<SELECT name="cmd">
<option value="releases">ShowReleases"</OPTION>
<option value="testplan">ShowTestPlan"</OPTION>
</SELECT>
<INPUT type="submit" value="Submit">
//
// What I want in the struts-config.xml file...
//
<!-- Display Releases -->
<action path="/planner?cmd=releases"
type="planner.ShowReleasesAction"
scope="request" >
<forward name="success" path="/ShowReleases.jsp"/>
</action>
<!-- Display Releases -->
<action path="/planner?cmd=testplan"
type="planner.ShowTestPlanAction"
scope="request" >
<forward name="success" path="/ShowTestPlan.jsp"/>
</action>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/