commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Wood <David.W...@thestreet.com>
Subject Indexed Array properties (that is, Indexes of Arrays)
Date Thu, 20 May 2004 21:05:17 GMT
What are people's feelings about supporting indexed properties with Array 
value types?

What I'd like to do is allow 

public String[] getIndexedArrayProperty(int index)
public void setIndexedArrayProperty(int index,String newvalue[])

Currently, this will fail with an IllegalArgumentException in 
PropertyUtilsBean, because setProperty will decide to store the first 
element of the newvalue array rather than the whole array. And in 
BeanUtils there is a getIndexedProperty and a getArrayProperty but no 
getIndexedArrayProperty. Is this for a particular reason? Or would it be 
appropriate to add the capability?

To give a bit more background, this is actually something I've been doing 
already with an "earlier" version of BeanUtils, and now I want to upgrade 
to the current commons version without (immediately) giving it up.

I found myself needing to do this to store various Struts "multibox" 
results (String[]) in an indexed property. This technique came from an 
application written against Struts 1.0, using the old 
struts.util.BeanUtils class. And this actually worked fine there - minus a 
typo-bug in the code (in populate). I have a 1-line patch that fixes it, 
and that's what I've been using. 

Now it's time to go to Struts 1.1, and a similar "fix" to commons 
BeanUtils might be useful for others, so I thought, lets see what everyone 
thinks? Esoteric, I know, but is there anything actually wrong with 
supporting indexed properties with an Array value type? 

Regards,
David

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message