commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [beanutils] getSimpleProperty
Date Tue, 23 Sep 2003 17:01:05 GMT
Nicolas.CHALUMEAU@arsoe-trelaze.com wrote:

>>Hello,
>>
>>not sure, whether I'm trapped in a gotcha.
>>I have a bean with several members and I would like to access them 
>>    
>>
>without 
>  
>
>>knowing the members, so I thought may be BeanUtils.getSimpleProperty() 
>>    
>>
>is the 
>  
>
>>right choice.
>>
>>One member is a Boolean with a setter and an is<memberName> getter (both 
>>    
>>
>have 
>  
>
>>public access. When I use getSimpleProperty, I receive an exception that 
>>    
>>
>
>  
>
>>reclaims, that <memberName> has no getter method.
>>
>>I thought, that boolean should have an is<memberName> getter. Do I have 
>>    
>>
>to 
>  
>
>>provide an additional get<memberName> getter for Booleans if I like to 
>>    
>>
>access 
>  
>
>>them with BeanUtils, or did I miss some other information?
>>    
>>
>
>Yes, you need to have get<memberName> for all attributes you want to 
>acces.
>  
>
That is not actually true if the data type is actually *boolean* (lower 
case "b").  In that scenario, it's perfectly legal to have the getter 
method start with "is" instead of "get".  The following is a legal 
read-write property:

  public boolean isStarted();
  public void setStarted(boolean started);

The following is not:

  public Boolean isStarted();
  public void setStarted(Boolean started);

>Nicolas
>  
>
Craig



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


Mime
View raw message