Hi,
I have 2 forms with the same button value i.e continue.In Scenario A, the click of the button should call method edit(),and in Scenario B, the click of the button should call method verify().
I have written an Action class that subclasses LookupDispatchAction.
My problem is that in my getKeyMethodMap() method of my Action, I am
trying unsuccessfully to map the method names to the button value.
This is how my getKeyMethodMap method looks like:
-----------------------------------------------------------
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("setup", "setup");
map.put("scenarioA.continue", "edit");
map.put("scenarioB.continue", "verify");
return map;
}
My property file has these entries.
Setup=setup
Verify=verify
scenarioA.continue= continue
scenarioB.continue= continue
---------------------------------------------------------------------
Can anyone suggest how I can achieve this in
Struts?
MY RESOLUTION:
I resolved the issue by mapping both of these to a method called getCorrectMethod where I checked for the value of a hidden field to determine which method to invoke.
-------------------------------------------------------
Code:
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("setup", "setup");
map.put("scenarioA.continue", "getCorrectMethod");
map.put("scenarioB.continue", "getCorrectMethod");
return map;
}
public ActionForward getCorrectMethod (
ActionContext context,
ActionMapping mapping,
BaseActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServiceFrameworkException, ActionFrameworkException {
String nextScreen = request.getParameter("screenName");
if (nextScreen.equals("ScenarioA")) {
return edit(context, mapping, form, request, response);
} else if (nextScreen.equals("ScenarioB")) {
return verify(context, mapping, form, request, response);
}
}
--------------------------------------------------------
But, I need to achieve this without using hidden fileds. DOes anyone have
a better resolution to t he p[roblem I am facing? It would be of immense help.
Thanks,
Scorp N.