Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Dispatch VS LookupDispatch

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • 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
  • 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"
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!