• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dispatch VS LookupDispatch

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error was gone after I did the change in jsp and config files. I am using paramater="method" in struts config and in jsp

<td><html:submit property="method"><bean:message key="button.edit"/></html:submit>

<td><html:submit property="method"><bean:message key="button.delete"/></html:submit>

I explisitly specified property="method". I red that if i use parameter="submit" struts submit tag has default name as submit. But some how it does not work.

But i stil have problem with when i press delete button , delete method was executed but it is trying to redirect to edit.jsp instead of success page as my jsp from action="edit.do"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic