You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Gogineni, Pratima" <pg...@selectica.com> on 2004/04/13 01:59:22 UTC

Re: [OT] Overloaded setters in JavaBeans

Hi,

I ran into the same problems of overloaded setters in particular for indexed
properties.  I have created a short Note based my observations if it is of
any help to other users.
Please comment/correct/add to the note...

Also i think the design patterns for list based indexed properties  is very
counterintuitive because: 
as per Java Bean spec following design pattern necessary for indexed
properties.
<PropertyType>[] get<PropertyName>(); 
public void set<PropertyName>(<PropertyType>[] value); 
<PropertyType> get<PropertyName>(int index); 
      public void set<PropertyName>(int index, <PropertyType> value);

BUT IF I try to create simulate an indexed property based on list (ofcourse
I havent found anything about indexed properties using LISTS in the java
spec so I am assuming this is a struts specific extension) I would have
thought the following would work but this results in the "overloading"
problem. I have to rename the indexed getter-setter pair for the whole thing
to work as I expect it to. 

List get<PropertyName>(); 
public void set<PropertyName>(List value); 
<PropertyType> get<PropertyName>(int index); 
      public void set<PropertyName>(int index, <PropertyType> value);


Pratima

 <<BeanDesign.txt>>