Hi, I am new to Jakarta Commons, and I don't use CVS to access the source code. However, I would like to submit an enhancement for BeanUtils.
I'm using Struts 1.1b2 and BeanUtils 1.4 for my web app. I created an ActionForm with an attribute of Map[]. public class NewForm extends ActionForm { private Map[] map; public Map getMap(int index) { return this.map[index]; } public Map[] getMap() { return this.map; } public void setMap(int index, Map map) { this.map[index] = map; } public void setMap(Map[] map) { this.map = map; } } Using this, I can populate the form with arbitrary keys and values like the following: ... for (int index=0; index < 10; index++) { Map map = new HashMap(2); map.put("id", "1"); map.put("groupid", "2"); maps[index] = map; } newForm.setMap(maps); .... My JSP can now display the contents of each map as input elements: <logic:iterate id="elem" name="newForm" property="map" type="java.util.Map"> id: <html:text name="elem" indexed="true" property="id" /> groupid: <html:text name="elem" indexed="true" property="groupid" /> </logic:iterate> The trouble is, when the form is submitted, the values inside the form elements are not updated. As it is, BeanUtils does not change the values because it does not find a setter method for "id" or "groupid". I patched BeanUtils with the following code: ... } else if ( target instanceof Map ) { // line 844 Map map = (Map) target; map.put(name, ConvertUtils.convert(value)); return; } else { ... Now, changes made to the html form are saved in the ActionForm. I hope that this patch can be added to the main distribution so others can also benefit. I welcome any corrections and comments to my suggestion, or if anyone knows better ways to do this. Thank you. Regards, Walter S. So __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com
BeanUtils.java
Description: BeanUtils.java
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>