Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DispatchAction:seems fine, but doesn't work

 
Ioana Mihaela
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,I have the following code:
public class AggrActAction extends DispatchAction {
public ActionForward execute(...){...}
public ActionForward create(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response) {
System.out.println("create");
return mapping.findForward("success");
}
}
in strus-config.xml:
<action-mappings >
<action
attribute="aggrForm"
input="/aggr.jsp"
name="aggrForm"
parameter="met"
path="/aggrAct"
scope="request"
type="com.yourcompany.struts.action.AggrActAction">
<forward name="success" path="/success.jsp" redirect="true"/>
</action>
</action-mappings>
in aggr.jsp:
<html:link action="aggrAct.do?met=create">Create</html:link>
or
<html:link action="/aggrAct?met=create">Create</html:link>
both links lead to the execution of execute method in AggrActAction and not create

Does anyone have a clue why it doesn't work?
Thank you.
 
Joseph Erickson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't be overridding the execute method, or at least you need to call super.execute() when you're done. The execute method of the DispatchAction is what is looking at that parameter and calling your create() method.
 
Ioana Mihaela
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, it works
(not overriding the execute method did the trick)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic