views:

314

answers:

1

My application is using Spring MVC. On the way from the Controller to the view we are taking adventage of this framwork by creating a bean of the model that is used to display the relevant properties through the JSP. On the way back however, meaning after submitting a form back to the controller, it is using a raw HTTPRequest instead of a structured formBean.

I think that this is a disadvantege so I am looking for way to insert this to our MVC model. I saw in this link some way that Spring MVC handles it. by adding to the JSP binding such as:

<spring:bind path="command">  <font color="red">    <b><c:out value="${status.errorMessage}"/></b>  
</font>
</spring:bind>

and to the controller:

 protected ModelAndView onSubmit(Object command) throws ServletException  
{    Widget widget = (Widget) command;
...
}

But this solution is not good for our implementation - I don't want to add anything to the JSP and in addition . some of the parameters that are added to the httprequest are done in javascript code. Therefore I am looking for a solution that can create formBean out of the form parameters while the mapping is not defined on the JSP but elsewhere (in some dedicated xml obviously).

Any ideas?

A: 

The simplest way to use a form (command) bean in Spring is to write a controller that extends SimpleFormController.

A quick Google shows a number of basic tutorials - for example:

http://www.vaannila.com/spring/spring-simple-form-controller-1.html

Joe
This is a very nice example. But it won't assist in my specific case since: 1. We are using controller that extends Spring's MultiActionController and not SimpleFormController so it doesn't support "onSubmit" function 2. it requires changing the client side code (jsp) and add to it 'form' from Spring's taglib. I am looking for a solution in which Spring will create the formBean without touching the View (JSP).
Spiderman
Perhaps there is no out-of-the-box solution and we will have to implement it using some interception. I still wait to see if there are other known solution here, from the knowledge of this smart community.
Spiderman