I have an Action extended to DsipatchAction with edit,delete methods.
My
jsp form action = "edit.do"
<td><html:submit property="method" value="edit" />
<td><html:submit property="method" value="delete" />
Struts config file is :
<action path="/edit" type="com.xxx.web.actions.LifeAAction"
name="dataForm" scope="session" parameter="method" validate="true" input="page.lifeA">
<forward name="edit" path="page.edit" />
</action>
<action path="/delete" type="com.xxx.web.actions.LifeAAction"
name="dataForm" scope="session" parameter="method">
<forward name="success" path="page.success" />
</action>
Edit calling th action and then jsp. But when i submit delete action it is calling action and exceuting delete method but it is trying to send to edit page again instead success page. Reason my jsp form action ="/edit.do".
Ok now I thought of using LookUpDispatchAction class.
I extended action to LookupDispatchAction then implimented
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.edit", "edit");
map.put("button.delete", "delete");
return map;
}
In JSP i chaged to :
<td><html:submit><bean:message key="button.edit"/></html:submit>
<td><html:submit><bean:message key="button.delete"/></html:submit>
I also changed parameter name from "method" to "submit" in struts config file
<action path="/edit" type="com.xxx.web.actions.LifeAAction"
name="dataForm" scope="session" parameter="
submit" validate="true" input="page.lifeA">
<forward name="edit" path="page.edit" />
</action>
<action path="/delete" type="com.xxx.web.actions.LifeAAction"
name="dataForm" scope="session" parameter="
submit">
<forward name="success" path="page.success" />
</action>
Now when i click edit I am getting the follwing error. Can some one point me?.
the example
http://www.husted.com/struts/tips/003.html is using
protected Map getKeyMethodMap(ActionMapping mapping,
ActionForm form,
HttpServletRequest request) {} with parameters but LookupDisptach action has method without signature. Not sure wich one is lates and to use.
[
Servlet Error]-[Request[/edit] does not contain handler parameter named submit]: javax.servlet.ServletException: Request[/edit] does not contain handler parameter named method
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java)
at javax.servlet.ServletException.<init>(ServletException.java:107)
at org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:199)
Thanks
Sudhakar