You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Aaron Mulder <am...@alumni.princeton.edu> on 2003/08/16 18:52:48 UTC

JavaBean Property Changes for Indexed Properties

	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?

Thanks,
	Aaron


Re: JavaBean Property Changes for Indexed Properties

Posted by Alex Blewitt <Al...@ioshq.com>.
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.