Results 1 to 4 of 4

Thread: return Map in formBackingObject, how to use in jsp ?

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    33

    Default Re: return Map in formBackingObject, how to use in jsp ?

    Quote 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

  3. #3
    Join Date
    Aug 2004
    Location
    Amsterdam, The Netherlands
    Posts
    10

    Default

    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 at 10:27 AM.
    -paul.

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    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

Similar Threads

  1. Forms
    By sherihan in forum Web
    Replies: 4
    Last Post: Oct 2nd, 2006, 06:24 AM
  2. LDAPPasswordAuthenticationDao problem
    By benoit_m35 in forum Security
    Replies: 15
    Last Post: Jan 11th, 2006, 07:04 AM
  3. Replies: 7
    Last Post: Aug 18th, 2005, 02:41 PM
  4. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  5. Replies: 0
    Last Post: Jun 6th, 2005, 09:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •