struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: basic struts question using a Map in an ActionForm
Date Thu, 14 Jul 2005 20:20:59 GMT
Rick Reumann wrote the following on 7/14/2005 3:17 PM:
> Ok this is basic, but I'm stumped here at the moment...
> 
> Imagine a Map of Animals. (Animal has a "name" property)
> 
> map.put(new Integer(1), new Animal() );
> map.put(new Integer(2), new Animal() );
> 
> In my Action form this map is in there as:
> 
> private Map animalsMap;
> getAnimalsMap()
> setAnimalsMap(Map map);
> 
> Question:
> 
> In this example I know the key names (1 and 2). I want to be able to 
> update the "name" for each animal that is in the map from a form:
> 
> <html:text property="animalsMap[1].name"/>
> <html:text property="animalsMap['1'].name"/>
> 
> <html:text property="animalsMap[2].name"/>

 From the FAQ I'm going to try this in my ActionForm..


  public Object getStringMapped(String key) {
         return map.get(key);
     }

     public void setStringMapped(String key, Object value) {
         map.put(key, value);
     }


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message