0

im using spring mvc 3.1.0 with jsp/jstl Please, how to use conversion with @ModelAttribute in spring mvc

i want to submit an object from my jsp page to the controller, my object contains a select tag of an object field in my class who is always submitted with null value.

there my object:

UorgVO.java

public class UorgVO {

private String nom;
private String nomAbrege;
private UorgVO refUniteOrganisParent ;
//getters&Setters..
}

and there is my jsp page:

<form:form method="post" action="saveUorg.html"  modelAttribute="uorg" >
<table >
<tr>
    <th>Nom</th>
    <th>Nom abregé</th>
    <th>Unité père</th>
</tr>
<tr>
    <td><input  type="text" path="nom" name="nom"/></td>
    <td><input  type="text" path="nomAbrege" name="nomAbrege"/></td>
    <td><select id="refUniteOrganisParent" name="refUniteOrganisParent" path="refUniteOrganisParent">
        <option  value="null"> --- </option> 
      <c:forEach items="${listeuos}" var="uorgg" varStatus="status" >
        <option value="${uorgg}">${uorgg} </option> 
      </c:forEach>
        </select>
    </td>
</tr>
</table> 
<input type="submit" value="Enregistrer uorg"  <BQ>  <a href="recherche_uorg.html">   Annuler</a>    
</form:form>

and my controller is:

    @RequestMapping(value ="/saveUorg", method = RequestMethod.POST)
    public ModelAndView saveUorg(@ModelAttribute("uorg") UorgVO uorg,BindingResult result){

    System.out.println("contenu du nom de l'UO est :" +uorg.getRefUniteOrganisParent());


    return new ModelAndView("uorg_recherche");  
    }   

and the printed value is null

Thank's in advance for help

Mouhie
  • 59
  • 2
  • 3
  • 16

1 Answers1

0

I guess you won't be able to bind nested objects with these forms. What you may want to look in to is Spring Binding Form. Refer here

Raunak Agarwal
  • 7,117
  • 6
  • 38
  • 62
  • i tried it but no result, i think i have to use converters but i don't know how i tried many times but it not works .. – Mouhie Jul 02 '13 at 11:31
  • I have done this type of binding before. I am sure this should have worked. Can you post the code using the spring binding tags – Raunak Agarwal Jul 02 '13 at 17:00
  • spring binding tags doesn't work in my code it leaves an error so im using just the model attribute. – Mouhie Jul 02 '13 at 17:10