You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael McGrady <mi...@michaelmcgrady.com> on 2004/04/21 17:18:16 UTC

Non-Form Based Mapped Properties

Is there a way to use non-form based mapped and indexed properties with 
bean and/or html tags?  Apparently not?



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


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Thanks, Herbert, let me state more particularly what I am doing.  I want to 
use Struts tags rather than JSP.  I know how to do things in JSP 
easily.  With the tags, outside of ActionForms, I am confused.  In JSP, I 
get my results as follows:


<%
Host host = (Host)session.getAttribute(SiteConstant.HOST);
Page key = (Page)host.getPage(SiteConstant.ECLIPSE_BANNER);
%>

<%= key.getValue("bannerLeftBackgroundColor") %>

I want to do with the Struts bean tag what I do now with JSP tags.  How do 
I do that?  This should be simple, but something is not working.  I am 
either erring with the "define" or the "write" attribute and all the 
combinations I try don't work.  People have indicated that I need to 
retrieve a Map object with getMap().  I don't see why, given what I read in 
the literature.  If you could help, I would be eternally (or a very long 
time) grateful. The classes are given below:

public class Host {
   private Map pages;

   public Host() {
     int size = 89;
     this.pages = Collections.synchronizedMap(new HashMap(size));
   }

   public void setMap(Map pages) {
     this.pages = pages;
   }

   public Map getMap() {
     return pages;
   }

   public void setPage(Object key, Object page) {
     pages.put(key,page);
   }

   public Object getPage(Object key) {
     return pages.get(key);
   }
} ///;-) Michael McGrady


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);
     com.crackwillow.log.StdOut.redirect("log.VALUE: " + value);
     if(value == null) {
       return "? [" + (String)key + "] ?";
     } else {
       return value;
     }
   }
} ///;-) Michael McGrady


At 05:02 AM 4/23/2004, Hubert Rabago wrote:
>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 <mi...@michaelmcgrady.com> 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" <mi...@michaelmcgrady.com> wrote in message
> > >news:6.0.1.1.0.20040422021524.01bdf148@mail.michaelmcgrady.com...
> > > > 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" <mi...@michaelmcgrady.com>
> > > > >To: "Struts Users Mailing List" <us...@struts.apache.org>;
> > > > ><us...@struts.apache.org>
> > > > >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: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org



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


Re: Non-Form Based Mapped Properties

Posted by Hubert Rabago <ja...@yahoo.com>.
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 <mi...@michaelmcgrady.com> 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" <mi...@michaelmcgrady.com> wrote in message
> >news:6.0.1.1.0.20040422021524.01bdf148@mail.michaelmcgrady.com...
> > > 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" <mi...@michaelmcgrady.com>
> > > >To: "Struts Users Mailing List" <us...@struts.apache.org>;
> > > ><us...@struts.apache.org>
> > > >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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
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" <mi...@michaelmcgrady.com> wrote in message
>news:6.0.1.1.0.20040422021524.01bdf148@mail.michaelmcgrady.com...
> > 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" <mi...@michaelmcgrady.com>
> > >To: "Struts Users Mailing List" <us...@struts.apache.org>;
> > ><us...@struts.apache.org>
> > >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
> > > > >
> > > > >
> > > > >---------------------------------------------------------------------
> > > > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > >For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org



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


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Thanks, Martin.  I want to use the getValue method with <bean:write 
name="foo" property="value(bar)".  I cannot do that?  I thought the whole 
point was to change the get and set of maps into getValue and setValue so 
that we could use reflection.  I must be confused, as usual

Michael

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" <mi...@michaelmcgrady.com> wrote in message
>news:6.0.1.1.0.20040422021524.01bdf148@mail.michaelmcgrady.com...
> > 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" <mi...@michaelmcgrady.com>
> > >To: "Struts Users Mailing List" <us...@struts.apache.org>;
> > ><us...@struts.apache.org>
> > >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
> > > > >
> > > > >
> > > > >---------------------------------------------------------------------
> > > > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > >For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org



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


Re: Non-Form Based Mapped Properties

Posted by Martin Cooper <ma...@apache.org>.
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" <mi...@michaelmcgrady.com> wrote in message
news:6.0.1.1.0.20040422021524.01bdf148@mail.michaelmcgrady.com...
> 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" <mi...@michaelmcgrady.com>
> >To: "Struts Users Mailing List" <us...@struts.apache.org>;
> ><us...@struts.apache.org>
> >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
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > >For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> > >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >For additional commands, e-mail: user-help@struts.apache.org




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


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
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" <mi...@michaelmcgrady.com>
>To: "Struts Users Mailing List" <us...@struts.apache.org>;
><us...@struts.apache.org>
>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
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org



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


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
I have getMap and setMap.  Also, I want to use bean:write rather than 
html:text.  What do you think?

Michael

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" <mi...@michaelmcgrady.com>
>To: "Struts Users Mailing List" <us...@struts.apache.org>;
><us...@struts.apache.org>
>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
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org



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


Re: Non-Form Based Mapped Properties

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
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" <mi...@michaelmcgrady.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>;
<us...@struts.apache.org>
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
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


Re: Non-Form Based Mapped Properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
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
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>



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


Re: Non-Form Based Mapped Properties

Posted by Bill Siggelkow <bi...@bellsouth.net>.
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


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