geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Blewitt <Alex.Blew...@ioshq.com>
Subject Re: JavaBean Property Changes for Indexed Properties
Date Sat, 16 Aug 2003 17:05:54 GMT
On Saturday, Aug 16, 2003, at 17:52 Europe/London, Aaron Mulder wrote:

> If I have an indexed property (an array) in a JavaBean, and one of
> the elements is changed (in place), what should the property change  
> event
> reflect?  Shoulf the "old" value be a copy of the entire old array, and
> the "new" value be the entire new array?  If the old and new should  
> only
> include the changed element, what should the property name be?

According to the JB spec, technically the 'old' value should be the  
'old' value, which means the old array.

JB would probably expect that the old value was the original array, and  
then the new value would be a (shallow) copy of that array with the new  
value in.

However, this would no doubt be hideously inefficient for even small  
arrays, and so the spec allows you to pass a 'null' in for the 'old'  
value, which means 'I don't know what the old value was'. Since (I'm  
guessing) most of the callers won't care about the old value, this  
should work fine.

[NB Most listeners probably don't check as strongly as they should when  
the 'old' or 'new' values are null, but that's their problem :-)]

http://java.sun.com/j2se/1.3/docs/api/java/beans/ 
PropertyChangeEvent.html

"Null values may be provided for the old and the new values if their  
true values are not known."

Alex.


Mime
View raw message