Results 1 to 2 of 2

Thread: Issue: Binding form fields with Map in command object

  1. #1
    Join Date
    Jun 2005
    Posts
    10

    Default Issue: Binding form fields with Map in command object

    Hi,

    It seems there is issue with spring in binding form fields with map in command object.

    Here is my code:
    Command Class
    Code:
    public class MyCommand {
    
    	private Map fields;
    
    	public Map getFieldsMap() {
    		return fields;
    	}
    
    	public void setFieldsMap(Map fields) {
    		this.fields = fields;
    	}
    }
    fields on from
    Code:
    	<c&#58;forEach var="field" items="$&#123;fields&#125;">
    <input value="" name="fieldsMap&#91;$&#123;field.name&#125;&#93;" type="text"/>
    	</c&#58;forEach>
    Above code throws exception.
    But if I initialize my Map objects explicitly as below it works fine
    Code:
    public class MyCommand &#123;
    
    	private Map fields = new HashMap&#40;&#41;;
    
    	public Map getFieldsMap&#40;&#41; &#123;
    		return fields;
    	&#125;
    
    	public void setFieldsMap&#40;Map fields&#41; &#123;
    		this.fields = fields;
    	&#125;
    &#125;
    Can anyone tell me how to log this bug in Spring Tracker. I am using Spring version 1.2.3

    Regards,
    Umesh

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    This isn't a bug, it is a misunderstanding

    Spring is binding to entries *within* your map, it isn't binding to the map itself.

    In otherwords, spring will never call
    Code:
    setFieldsMap(..);
    it will only ever call
    Code:
    getFieldsMap().get(whatever your field name is);
    Checkout http://forum.springframework.org/showthread.php?t=17646 for a bit more info on this.
    Last edited by robyn; May 14th, 2006 at 10:18 AM.

Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 6
    Last Post: Sep 24th, 2006, 11:58 AM
  3. Replies: 2
    Last Post: Aug 4th, 2006, 01:37 PM
  4. Replies: 2
    Last Post: Aug 17th, 2004, 04:16 PM
  5. Submission of empty form fields
    By steven.warren in forum Web
    Replies: 7
    Last Post: Aug 17th, 2004, 03:36 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
  •