Michael,

The tag eventually ends up calling BeanUtils'
PropertyUtils.getNestedProperty(), which has special handling for
collections, including maps.  It's actually pretty powerful.  It enables
resolving Strings that eventually results in an object or an object's
property.  With it, bean:write (or any caller; it's a public method) can
resolve strings like "map1(foo).bar[2].name", with the proper object, of
course.  Also, AFAIK, its use isn't tied to ActionForms or DynaBeans.

Hubert

--- Michael McGrady <[EMAIL PROTECTED]> wrote:
> How can this be, Martin, when the method getMap() has no parameters?  What 
> is the point of the getValue/setValue methods?  This is very confusing to 
> me at this point.
> 
> At 10:33 AM 4/22/2004, Martin Cooper wrote:
> >What are you actually trying to do, Michael? Given the code you have
> below,
> >and assuming you have a Page instance stored as an attribute named "foo"
> and
> >want to print out the value of the "bar" entry in your map, this might be
> >what you want:
> >
> ><bean:write name="foo" property="map(bar)"/>
> >
> >The "map" refers to your getMap/setMap property - you can call it whatever
> >you want. Your getValue/setValue methods won't be used.
> >
> >--
> >Martin Cooper
> >
> >
> >"Michael McGrady" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> > > The class is the following, Niall:
> > >
> > > import java.util.Collections;
> > > import java.util.HashMap;
> > > import java.util.Map;
> > >
> > > public class Page {
> > >    private Map keys;
> > >
> > >    public Page() {
> > >      int size = 89;
> > >      this.keys = Collections.synchronizedMap(new HashMap(size));
> > >    }
> > >
> > >    public void setMap(Map keys) {
> > >      this.keys = keys;
> > >    }
> > >
> > >    public Map getMap() {
> > >      return keys;
> > >    }
> > >
> > >    public void setValue(Object key, Object value) {
> > >      keys.put(key,value);
> > >    }
> > >
> > >    public Object getValue(Object key) {
> > >      Object value = keys.get(key);
> > >      if(value == null) {
> > >        return "? [" + (String)key + "] ?";
> > >      } else {
> > >        return value;
> > >      }
> > >    }
> > > } ///;-) Michael McGrady
> > >
> > > At 04:22 PM 4/21/2004, Niall Pemberton wrote:
> > > >Haven't done this but either your class needs to be a Map
> implementation
> >or
> > > >you need getter/setter for your Map
> > > >
> > > >      public void setMyMap(Map myMap)
> > > >      public Map getMyMap()
> > > >
> > > >The problem with using the <html> tags and not having your Map as a
> >property
> > > >of the ActionForm is that when the form is submitted, Struts is going
> to
> >try
> > > >to populate these properties in the form.
> > > >
> > > >Niall
> > > >
> > > >----- Original Message -----
> > > >From: "Michael McGrady" <[EMAIL PROTECTED]>
> > > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]>;
> > > ><[EMAIL PROTECTED]>
> > > >Sent: Wednesday, April 21, 2004 11:50 PM
> > > >Subject: Re: Non-Form Based Mapped Properties
> > > >
> > > >
> > > > > I created a simple class with the map and setValue(Object key,
> Object
> > > > > value) as well as getValue(Object key).  Then tested the class by
> >putting
> > > > > an instance of the class into session scope on a page, retrieving
> the
> > > > > object on the same page, and trying to access the properties via
> the
> > > >mapped
> > > > > properties value("keyName").  I made sure the object was obtained
> via
> >the
> > > > > logic tag, but the mapped property does not work for me.  Any
> ideas?
> >If
> > > > > not, I will put the whole thing into this exchange.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > Michael
> > > > >
> > > > > At 08:56 AM 4/21/2004, Bill Siggelkow wrote:
> > > > > >Michael McGrady wrote:
> > > > > >>Is there a way to use non-form based mapped and indexed
> properties
> >with
> > > > > >>bean and/or html tags?  Apparently not?
> > > > > >
> > > > > >Yes -- you can used both mapped and indexed properties from normal
> > > > > >JavaBeans.  You can be more specific on the problem you are
> having?
> > > > > >
> > > > > >Bill Siggelkow
> > > > > >



        
                
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to