Announcement Announcement Module
No announcement yet.
SimpleFromController and binding multiple objects Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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"/>

    (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();
    user.setUserName(request.getParameter("userName")) ;
    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

  • #2
    Hi riboriori,

    Plz have a look at the chapter 14 of spring doc"

    The SimpleFormController takes care of binding of the subobjects also.

    Best Regards


    • #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