PDA

View Full Version : Chaining/Redirecting Actions


mayank76
Aug 10th, 2007, 03:35 PM
Hi,

How do we chain actions or conditional behavior in Spring..? . I have a list page and onSubmit redirects to same page ( mv = showForm(request,response, errors)). But for some custom action on list, I need to submit the form and invoke/redirect to detail controller. I am able to bring up the detail View form, but on submit it redirect back to list view, instead of returning back to detail view. I need to stay back on detail page after the form is submitted. I am also using tiles for page layout. Any advice Please.

ListConrtroller:
---------------
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception {

if (cmdEvt.isCustomCommand() && cmdEvt.getCommandName().equals("custom:view")) {
request.getRequestDispatcher("/trandetail.jsp").forward(request,response);
}else{
mv = showForm(request,response, errors);

}
return mv;
}

DetailController:
---------------

protected void doSubmitAction(Object object) throws Exception {
logger.info("Save Data and redirect to formView/Success View");
}

trandetail.jsp
------------

<tiles:insertDefinition name="HLDR.default">
<tiles:putAttribute type="template" name="body-content" value="/trandetail.htm" />
</tiles:insertDefinition>

Config:
-------
<bean name="/tranlist.htm" class="com.hldrs.web.controller.FormControllertranList">
<property name="commandName" value="listForm"/>
<property name="commandClass" value="com.hldrs.web.domain.ListForm"/>
<property name="formView" value="HolderList"/>
<property name="transactionService" ref="transactionService"/>
</bean>

<bean name="/trandetail.htm" class="com.hldrs.web.controller.FormControllertranDetail">
<property name="commandName" value="tranDetailForm"/>
<property name="commandClass" value="com.hldrs.web.domain.TranDetailForm"/>
<property name="formView" value="CreateTransaction"/>
<property name="successView" value="CreateTransaction"/>
<property name="transactionService" ref="transactionService"/>
</bean>