PDA

View Full Version : Problem with SimpleFormController



tareq
Aug 31st, 2004, 10:53 AM
Hi,
I am using a controller with SimpleFormController as base class and I am getting an exception the first time I go to the page :
javax.servlet.ServletException: Could not find Errors instance for bean [MyBean] in request: add the Errors model to your ModelAndView via errors.getModel()
here is the method I implemented in my controller :


protected void doSubmitAction(Object command) throws Exception {
log.info(command);
}

and here is the jsp view :


<spring&#58;bind path="MyBean.text">
<input type="text" name="$&#123;status.expression&#125;">
</spring&#58;bind>

Any idea ?

dmiller
Aug 31st, 2004, 09:54 PM
Try this if MyBean is the command object:


<spring&#58;bind path="command.text">
<input type="text" name="$&#123;status.expression&#125;">
</spring&#58;bind>

or this if your command object has a "myBean" property (e.g. getMyBean):


<spring&#58;bind path="command.myBean.text">
<input type="text" name="$&#123;status.expression&#125;">
</spring&#58;bind>

I am assuming that you have not changed the default commandName of your controller. If you have changed it, substitute "command" in the above examples with your custom commandName.

Also note that if you want the text box to be initialized with the value of the "text" property you will need to do this:


<input type="text" name="$&#123;status.expression&#125;" value="$&#123;status.value&#125;">

tareq
Sep 1st, 2004, 03:35 AM
thanks a lot. It worked !