Dear all,
Probably this is a very naif question but I'm being around this problem for some hours now and I'm not able to see where's the error. I've a very simple FormController, FormValidator and the jsp form like:
Code:<bean name="/CreateAllocation.htm" class="administration.web.CreateAllocationController"> <property name="sessionForm" value="true" /> <property name="commandName" value="addAllocation" /> <property name="commandClass" value="administration.service.AddAllocation" /> <property name="validator"> <bean class="administration.service.AddAllocationValidator" /> </property> <property name="formView" value="/FundCreateAllocation" /> <property name="successView" value="Home.htm" /> <property name="manager" ref="manager" /> </bean>
The AddAllocation class:
Code:public class AddAllocation { protected final Log logger = LogFactory.getLog(getClass()); private float percentage; private float totalPercentage; public void setPercentage(float i) { percentage = i; logger.info("Percentage set to " + i); } public float getPercentage() { return percentage; } public float getTotalPercentage(){ return totalPercentage; } }
The form controller:
Code:public class FundCreateAllocationController extends SimpleFormController { protected final Log logger = LogFactory.getLog(getClass()); private Manager manager; public ModelAndView onSubmit(Object command) throws ServletException { AddAllocation f = (AddAllocation) command; logger.info("returning from Create Allocation Form view to " + getSuccessView()); return new ModelAndView(new RedirectView(getSuccessView())); } protected Object formBackingObject(HttpServletRequest request) throws ServletException { AddAllocation addAllocation = new addAllocation(); return addAllocation; } protected Map referenceData(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, BindException arg3) throws Exception { logger.info("Sending Create Allocation Model"); return myModel; } public void setManager(Manager manager) { this.Manager = manager; } public Manager getManager(){ return manager; }
The Validator
The jsp:Code:public class FundAddAllocationValidator implements Validator { protected final Log logger = LogFactory.getLog(getClass()); public boolean supports(Class clazz) { return clazz.equals(AddAllocation.class); } public void validate(Object command, Errors errors) { logger.info("Validating Form Add Allocation..."); } }
My problem with this example is that, when I load the CreateAllocation.htm page, it loads the Home.htm page automatically and, in the Tomcat console I get the:Code:<form:errors path="percentage" cssClass="error"/><br/> <form:form method="POST" commandName="addAllocation"> <input type="submit" value="Submit"> <form:input path="percentage"/> </form:form>
method of Validator is called and so it is the onSubmit method of the controller.Code:INFO: Validating Form Add Allocation... INFO: returning from Create Allocation Form view to Home.htm
Any idea what I'm doing wrong?
Thank you very much in advance for your time and help.
Luis


Reply With Quote