You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Winterfeldt <dw...@yahoo.com> on 2001/01/22 18:58:42 UTC

How to access Collection size()

Is there anyway to override the tags always adding
property get in front of a method?  I would like to
call size() on a collection to see if it is zero.  I
don't see a way to do this with the tags.  If there is
a way, any help would be appreciated.   If there isn't
a way, would it be possible to add a facility into the
tags like property="false" so it won't add a get in
front of methods that don't follow the standard
property naming conventions?

David

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

Re: How to access Collection size()

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
David Winterfeldt wrote:

> Is there anyway to override the tags always adding
> property get in front of a method?  I would like to
> call size() on a collection to see if it is zero.  I
> don't see a way to do this with the tags.  If there is
> a way, any help would be appreciated.   If there isn't
> a way, would it be possible to add a facility into the
> tags like property="false" so it won't add a get in
> front of methods that don't follow the standard
> property naming conventions?
>

The JavaBeans spec describes approaches to dealing with non-standard method
names by using a BeanInfo or BeanDescriptor class along with your beans.  The
reflection code used by PropertyUtils will respect such names, so you should be
able to do things like this.

However, I've never tried creating a BeanInfo for a JDK class like
java.util.HashMap -- it will be interesting to see if that actually works.

>
> David
>

Craig