-
Aug 23rd, 2008, 03:42 AM
#1
SimpleFromController and binding multiple objects
Hi all,
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:
<spring:bind path="command.user.userName">
<input type="text" name = userName"/>
</spring:bind>
(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;
System.out.println(entity.getUser.getUserName);
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();
user.setUserName(request.getParameter("userName")) ;
entity.setUser(user);
return 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)?
Other infos:
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??
Best regards
Edit/Delete Message
-
Aug 23rd, 2008, 04:30 AM
#2
Hi riboriori,
Plz have a look at the chapter 14 of spring doc
http://static.springframework.org/spring/docs/2.5.x/reference/view.html"
The SimpleFormController takes care of binding of the subobjects also.
Best Regards
Madhu
-
Aug 23rd, 2008, 03:20 PM
#3
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.
best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules