Announcement Announcement Module
Collapse
No announcement yet.
return Map in formBackingObject, how to use in jsp ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • return Map in formBackingObject, how to use in jsp ?

    hi,

    I need to use 2 object in my jsp page can i use a map for this ?

    Code:
    protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    Map map=new HashMap(); 
    map.put("carteAutoroute",new CarteAutoroute());
    map.put("historiqueCarteAutoroute",new HistoriqueCarteAutoroute());
    return map;
    }
    How to bind in the jsp code ? I try :

    Code:
    <spring&#58;bind path="map&#91;\"carteAutoroute\"&#93;.id">
    <input type="hidden" name="id" value="$&#123;status.value&#125;"/>
    </spring&#58;bind>
    But not succefully...,

    Thanks,

    Fabien.

  • #2
    Re: return Map in formBackingObject, how to use in jsp ?

    Originally posted by fmourioux
    hi,

    Code:
    <spring&#58;bind path="map&#91;\"carteAutoroute\"&#93;.id">
    <input type="hidden" name="id" value="$&#123;status.value&#125;"/>
    </spring&#58;bind>
    Seems to me like design problem having two backing objects in one controller, but anyway if You didn't configure Your command name in application context for given controller you should use "command" (this is default) as name of your form bean.

    So use path="command['carteAutoroute'].id"

    Artur

    Comment


    • #3
      I had this problem as well recently. I couldn't get the Map as a formBackingObject to work. I think, but I not sure, that property paths like "command['firstObject'].name" are not supported by the BeanWrapper's get/setPropertyValue methods.

      I defined and used a helper bean instead as the formBackingObject. That works OK, and indexed references in paths like "command[0].name" are supported. These work for both Lists and Arrays.

      You can always try them out calling the BeanWrapper directly; see this topic: http://forum.springframework.org/showthread.php?t=10783.

      Good luck!
      Last edited by robyn; May 14th, 2006, 10:27 AM.

      Comment


      • #4
        We're not using maps as our command objects, but we do have maps in some cases as properties of the command objects.

        e.g. command.someMapProperty[someMapKey]

        where someMapProperty is public Map getSomeMapProperty();

        We don't use quotes around the map key...so maybe you can try this?

        i.e.

        command[firstObject].name

        instead of

        command['firstObject'].name

        Comment

        Working...
        X