Aug 23rd, 2008, 03:42 AM
SimpleFromController and binding multiple objects
this is my first post on this forum, and i'm new to spring.
I'm developing a simple page, in wich i put some input field as criteria for searching results on a db.
The problem is that the input fields are related to differerent properties on hibernate pojo, on my domain package.
(i'm using annotations).
I'm confusing about binding at jsp-level, when i've multiple beans as a single command object.
I've maked another class that i calles "Entities", wich has my hibernate pojo as properties, in wich i addedd canonical getters and setters.
In my jsp i've used the <srping:bind> tags, so, for example:
<input type="text" name = userName"/>
(Suppose that in my jsp there are other fields, related to other pojos, as departements and so on).
I've noticed that in my overrided OnSubmit method, if i get the Entities object as:
Entities entity = (Entities) command;
The System.out.println produces a null value: this is because the binding does not happens.
So i must override the formBackingObject method and:
User user = new User();
Entities entity = new Entity();
In this way it works, but i must "force" to insert the correct values into the entities class, by processing the request.
There is a way in order to populate automatically my Entities class (and related sub-objects, as User object, Departements object)?
1) In my spring definition of controller, i've settes the commandClass to Entities class.
2) form view and success view are different.
Can someone help me??
Aug 23rd, 2008, 04:30 AM
Plz have a look at the chapter 14 of spring doc
The SimpleFormController takes care of binding of the subobjects also.
Aug 23rd, 2008, 03:20 PM
tank you for the reply. Now i was resolved my problem, and i am able
to bound at jsp level complex object and send it to server.