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 21:11:16 UTC

Overloaded setters in JavaBeans & Access through Struts Tags

Apologies if this was already posted. I requested the digest as well as
looked at the archives & didnt find the below message. So Im assuming it did
not get posted.

>  -----Original Message-----
> From: 	Gogineni, Pratima  
> Sent:	Monday, April 12, 2004 4:59 PM
> To:	'struts-user@jakarta.apache.org'; 'craigmcc@apache.org'
> Subject:	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
> 
>  << File: BeanDesign.txt >>  [Gogineni, Pratima]   <<BeanDesign.txt>>