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/07/15 00:28:16 UTC

LabelValueBean and BeanMap with and for indexed properties

I am using my version of a BeanMap built for instrumentation, cf. 
http://wiki.apache.org/struts/StrutsCatalogMappedBeans, and am putting a 
series of java.util.LinkedLists holding 
org.apache.struts.util.LabelValueBeans into the BeanMap via 
setProperty(Object key,Object value).  I am then accessing the lists via 
<logic:iterator> in Struts radio tags (where "eclipse" is a key in the 
BeanMap holding a list of LabelValueBeans) as follows:


               <logic:iterate id="row" name="layouts_schemes" 
property="eclipse">
                 <html:radio property="scheme" value="value" idName="row"/>
                 <bean:write name="row" property="label"/>
               </logic:iterate>

This works great!  However, I am not sure that this behavior will be 
guaranteed in the future, since it is not documented in the docs.

In the docs, the property for iterator is "defined" as the

   	"Name of the property, of the JSP bean specified by name, whose getter 
returns the collection to be iterated".

Obviously, my code sneaks in the value of the property attribute as the

	"Name of the key in the BeanMap which returns the Collection saved is 
scope as "layouts_schemes"

Trust me, if I change the property value to a different key in the BeanMap, 
I do get a different collection (List) from the BeanMap on the page.  My 
question is whether this will be guaranteed in the future. Or, is this an 
anomaly that I cannot count on in the future?  Anyone have an inkling on that?

Thanks!

Michael



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


Re: LabelValueBean and BeanMap with and for indexed properties

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
No I see no difficulty in relying on it. I was just saying the same as Joe
had already said but I just thought it would give you more comfort to know
the principle that the beanutils committers are working on.

Just for information, the inconsistency issue currently in beanutils is
where you have a bean that extends a Map but also implements some simple
properties.

For example

public class MyBean extends Map {

   protected String foo;
   public void setFoo(String foo) {
      this.foo= foo;
   }
   public String getFoo() {
      return foo;
   }
}

Currently if you call PropertyUtils.setProperty("foo", "bar") then beanutils
would set the value in the "foo" property rather than the Map. But using
PropertyUtils.getProperty("foo") ignores the "foo" property and only looks
for an entry in the Map with a key of "foo".

Its likely that beanutils will change in the future so that the "setter"
works in the same way as the "getter".

Niall

----- Original Message ----- 
From: "Michael McGrady" <mi...@michaelmcgrady.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, July 15, 2004 1:04 PM
Subject: Re: LabelValueBean and BeanMap with <html:radio> and
<logic:iterator> for indexed properties


> At 03:52 AM 7/15/2004, you wrote:
> >There are currently some discrepencies in beanutils where the above
> >statement isn't followed - but, from the discussion over on commons, its
> >likely that in a  future version of beanutils it will be changed so that
it
> >is always consistent with the above statement.
> >
> >Niall
>
>
> Niall, what is the upshot of your observation?  Does this mean that, in
> your view, I am likely nor not likely to see a difficulty if I rely upon
> this undocumented use of <logic:iterate> and bean utils?
>
> Thanks,
>
> Michael
>
>
>
>
> ---------------------------------------------------------------------
> 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: LabelValueBean and BeanMap with and for indexed properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
At 03:52 AM 7/15/2004, you wrote:
>There are currently some discrepencies in beanutils where the above
>statement isn't followed - but, from the discussion over on commons, its
>likely that in a  future version of beanutils it will be changed so that it
>is always consistent with the above statement.
>
>Niall


Niall, what is the upshot of your observation?  Does this mean that, in 
your view, I am likely nor not likely to see a difficulty if I rely upon 
this undocumented use of <logic:iterate> and bean utils?

Thanks,

Michael




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


Re: LabelValueBean and BeanMap with and for indexed properties

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I've been doing a bit of work on PropertyUtils bugs recently and discussing
some discrepencies with how simple/mapped properties are handled between the
different methods with a couple of the other beanutils committers.

Quoting from Craig McClanahan....

"The standard implementations of expression evaluation (JSTL 1.0/1.1, JSP
2.0, JSF 1.0/1.1) all conform to the way that BeanUtils currently works -- 
if the object you pass implements Map, it is *always* treated as a  Map."

There are currently some discrepencies in beanutils where the above
statement isn't followed - but, from the discussion over on commons, its
likely that in a  future version of beanutils it will be changed so that it
is always consistent with the above statement.

Niall

----- Original Message ----- 
From: "Michael McGrady" <mi...@michaelmcgrady.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, July 15, 2004 2:49 AM
Subject: Re: LabelValueBean and BeanMap with <html:radio> and
<logic:iterator> for indexed properties


> Thanks, Joe.  I expect you are right, but it is comforting to hear it.
>
> Michael
>
> At 04:06 PM 7/14/2004, you wrote:
> >Michael:
> >
> >This is ultimately a function performed by commons-beanutils, not Struts
> >itself.  Specifically, o.a.c.beanutils.PropertyUtils has a method,
> >"getProperty(Object, String) which returns the object value of the bean
> >property.  (Internally, that's actually forwarded to
> >getNestedProperty(Object, String) but the end result is the same...)
> >
> >Anyway, while it's not explicit in the docs, it is explicit in the
code -- 
> >if the Object passed to PropertyUtils implements java.util.Map, then the
> >String passed in is used as a key to the map to get the value to
> >return.  As much as you trust the developers of beanutils to maintain
> >backwards compatibility, you can count on this. I'd say you're pretty
safe.
> >
> >Joe
> >
> >
> >At 3:28 PM -0700 7/14/04, Michael McGrady wrote:
> >>I am using my version of a BeanMap built for instrumentation, cf.
> >>http://wiki.apache.org/struts/StrutsCatalogMappedBeans, and am putting a
> >>series of java.util.LinkedLists holding
> >>org.apache.struts.util.LabelValueBeans into the BeanMap via
> >>setProperty(Object key,Object value).  I am then accessing the lists via
> >><logic:iterator> in Struts radio tags (where "eclipse" is a key in the
> >>BeanMap holding a list of LabelValueBeans) as follows:
> >>
> >>
> >>               <logic:iterate id="row" name="layouts_schemes"
> >> property="eclipse">
> >>                 <html:radio property="scheme" value="value"
idName="row"/>
> >>                 <bean:write name="row" property="label"/>
> >>               </logic:iterate>
> >>
> >>This works great!  However, I am not sure that this behavior will be
> >>guaranteed in the future, since it is not documented in the docs.
> >>
> >>In the docs, the property for iterator is "defined" as the
> >>
> >>         "Name of the property, of the JSP bean specified by name, whose
> >> getter returns the collection to be iterated".
> >>
> >>Obviously, my code sneaks in the value of the property attribute as the
> >>
> >>         "Name of the key in the BeanMap which returns the Collection
> >> saved is scope as "layouts_schemes"
> >>
> >>Trust me, if I change the property value to a different key in the
> >>BeanMap, I do get a different collection (List) from the BeanMap on the
> >>page.  My question is whether this will be guaranteed in the future. Or,
> >>is this an anomaly that I cannot count on in the future? Anyone have an
> >>inkling on that?
> >>
> >>Thanks!
> >>
> >>Michael
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >--
> >Joe Germuska
> >Joe@Germuska.com
> >http://blog.germuska.com
> >"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back;
> >I'll know I'm in the wrong place."
> >    - Carlos Santana
>
>
>
> ---------------------------------------------------------------------
> 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: LabelValueBean and BeanMap with and for indexed properties

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Thanks, Joe.  I expect you are right, but it is comforting to hear it.

Michael

At 04:06 PM 7/14/2004, you wrote:
>Michael:
>
>This is ultimately a function performed by commons-beanutils, not Struts 
>itself.  Specifically, o.a.c.beanutils.PropertyUtils has a method, 
>"getProperty(Object, String) which returns the object value of the bean 
>property.  (Internally, that's actually forwarded to 
>getNestedProperty(Object, String) but the end result is the same...)
>
>Anyway, while it's not explicit in the docs, it is explicit in the code -- 
>if the Object passed to PropertyUtils implements java.util.Map, then the 
>String passed in is used as a key to the map to get the value to 
>return.  As much as you trust the developers of beanutils to maintain 
>backwards compatibility, you can count on this. I'd say you're pretty safe.
>
>Joe
>
>
>At 3:28 PM -0700 7/14/04, Michael McGrady wrote:
>>I am using my version of a BeanMap built for instrumentation, cf. 
>>http://wiki.apache.org/struts/StrutsCatalogMappedBeans, and am putting a 
>>series of java.util.LinkedLists holding 
>>org.apache.struts.util.LabelValueBeans into the BeanMap via 
>>setProperty(Object key,Object value).  I am then accessing the lists via 
>><logic:iterator> in Struts radio tags (where "eclipse" is a key in the 
>>BeanMap holding a list of LabelValueBeans) as follows:
>>
>>
>>               <logic:iterate id="row" name="layouts_schemes" 
>> property="eclipse">
>>                 <html:radio property="scheme" value="value" idName="row"/>
>>                 <bean:write name="row" property="label"/>
>>               </logic:iterate>
>>
>>This works great!  However, I am not sure that this behavior will be 
>>guaranteed in the future, since it is not documented in the docs.
>>
>>In the docs, the property for iterator is "defined" as the
>>
>>         "Name of the property, of the JSP bean specified by name, whose 
>> getter returns the collection to be iterated".
>>
>>Obviously, my code sneaks in the value of the property attribute as the
>>
>>         "Name of the key in the BeanMap which returns the Collection 
>> saved is scope as "layouts_schemes"
>>
>>Trust me, if I change the property value to a different key in the 
>>BeanMap, I do get a different collection (List) from the BeanMap on the 
>>page.  My question is whether this will be guaranteed in the future. Or, 
>>is this an anomaly that I cannot count on in the future? Anyone have an 
>>inkling on that?
>>
>>Thanks!
>>
>>Michael
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>
>
>--
>Joe Germuska
>Joe@Germuska.com
>http://blog.germuska.com
>"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; 
>I'll know I'm in the wrong place."
>    - Carlos Santana



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


Re: LabelValueBean and BeanMap with and for indexed properties

Posted by Joe Germuska <Jo...@Germuska.com>.
Michael:

This is ultimately a function performed by commons-beanutils, not 
Struts itself.  Specifically, o.a.c.beanutils.PropertyUtils has a 
method, "getProperty(Object, String) which returns the object value 
of the bean property.  (Internally, that's actually forwarded to 
getNestedProperty(Object, String) but the end result is the same...)

Anyway, while it's not explicit in the docs, it is explicit in the 
code -- if the Object passed to PropertyUtils implements 
java.util.Map, then the String passed in is used as a key to the map 
to get the value to return.  As much as you trust the developers of 
beanutils to maintain backwards compatibility, you can count on this. 
I'd say you're pretty safe.

Joe


At 3:28 PM -0700 7/14/04, Michael McGrady wrote:
>I am using my version of a BeanMap built for instrumentation, cf. 
>http://wiki.apache.org/struts/StrutsCatalogMappedBeans, and am 
>putting a series of java.util.LinkedLists holding 
>org.apache.struts.util.LabelValueBeans into the BeanMap via 
>setProperty(Object key,Object value).  I am then accessing the lists 
>via <logic:iterator> in Struts radio tags (where "eclipse" is a key 
>in the BeanMap holding a list of LabelValueBeans) as follows:
>
>
>               <logic:iterate id="row" name="layouts_schemes" 
>property="eclipse">
>                 <html:radio property="scheme" value="value" idName="row"/>
>                 <bean:write name="row" property="label"/>
>               </logic:iterate>
>
>This works great!  However, I am not sure that this behavior will be 
>guaranteed in the future, since it is not documented in the docs.
>
>In the docs, the property for iterator is "defined" as the
>
>  	"Name of the property, of the JSP bean specified by name, 
>whose getter returns the collection to be iterated".
>
>Obviously, my code sneaks in the value of the property attribute as the
>
>	"Name of the key in the BeanMap which returns the Collection 
>saved is scope as "layouts_schemes"
>
>Trust me, if I change the property value to a different key in the 
>BeanMap, I do get a different collection (List) from the BeanMap on 
>the page.  My question is whether this will be guaranteed in the 
>future. Or, is this an anomaly that I cannot count on in the future? 
>Anyone have an inkling on that?
>
>Thanks!
>
>Michael
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana