problems with onSubmit()
Hi,
I'm currently trying to add an onSubmit() (org.springframework.web.servlet.mvc.SimpleFormController) to a webpage I'm currently developing. I am required to take a comment from a textarea, update the object and reload the page, displaying the new comment in the textarea. The page is implemented with the MVC approach. The code for the form in my jsp is:
<form method="post" action="<c:url value="/baseListCustom.html"/>" id="baseListForm" onsubmit="return validatebaseList(this)">
<spring:bind path="baseList.id">
<input type="hidden" name="${status.expression}" value="${status.value}"/>
</spring:bind>
<delta:label styleClass="desc" key="baseList.comments"/>
<spring:bind path="baseList.commentString">
<span class="fieldError">${status.errorMessage}</span>
<textarea name="${status.expression}" id="${status.expression}" cols="15" rows="4">${status.value}</textarea>
</spring:bind>
<input type="submit" class="button" name="save" onclick="bCancel=false" value="<fmt:message key="baseListCustom.update"/>" />
</form>
The code for the controller 'basListCustomController' is:
public class BaseListCustomController implements Controller {
private final Log log = LogFactory.getLog(getClass());
private BaseListManager baseListManager = null;
BaseListCommentFormController b = new BaseListCommentFormController();
public void setBaseListManager(BaseListManager baseListManager) {
this.baseListManager = baseListManager;
}
protected Object formBackingObject(HttpServletRequest request)
throws Exception {
String id = request.getParameter("id");
BaseList baseList = null;
if (!StringUtils.isEmpty(id)) {
baseList = baseListManager.getBaseList(id);
} else {
baseList = new BaseList();
}
return baseList;
}
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String id = request.getParameter("baseListId");
BaseList baseList = null;
if (!StringUtils.isEmpty(id)) {
baseList = baseListManager.getBaseList(id);
} else {
baseList = new BaseList();
}
//lock or unlock evaluation weights?
log.debug("====================================================");
log.debug("in BaseListCustomControllers - handleRequest .......");
log.debug("====================================================");
String evaluationLock = request.getParameter("lock");
if (evaluationLock!=null){
baseList.setEvaluationLock(evaluationLock.equals("lock")?true:false);
log.debug("have set evaluationLock to :"+baseList.getEvaluationLock());
baseListManager.saveBaseList(baseList);
//log
}
Set supplierLists = baseList.getSupplierList();
String view = "baseListCustom";
ModelAndView mav = new ModelAndView(view);
mav.addObject("supplierLists", supplierLists);
mav.addObject("baseList", baseList);
return mav;
}
public ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response)
throws Exception {
log.debug("====================================================");
log.debug("in BaseListCustomControllers - ONSUBMIT!!! .......");
log.debug("====================================================");
String id = request.getParameter("baseListId");
BaseList baseList = null;
if (!StringUtils.isEmpty(id)) {
baseList = baseListManager.getBaseList(id);
} else {
baseList = new BaseList();
}
Set supplierLists = baseList.getSupplierList();
String view = "baseListCustom";
ModelAndView mav = new ModelAndView(view);
mav.addObject("supplierLists", supplierLists);
mav.addObject("baseList", baseList);
return mav;
}
}
and my bean in the action-servlet.xml is:
<bean id="baseListCustomController" class="com.bipsolutions.delta.sid.buyer.webapp.action.BaseListCustomController" autowire="byName">
<property name="baseListManager"><ref bean="baseListManager"/></property>
</bean>
When I click submit I am successfully returned to the page, but the comment field is not updated. By use of the log.debug(), i have found that the onSubmit() method is not being accessed.
thanks
null

