Skip to main content

AbstractBean JavaDoc

1 reply [Last post]
Anonymous

If you look at the class JavaDoc for AbstractBean, it correctly points
out that if a listener fires a veto exception the property should not
change. However, the example code provided changes the value before the
listeners have a chance to throw an exception. My understanding is that
to update a constrained property value, a bean uses the following three
phase approach:

1. Notify all vetoable change listeners of the intent to change the
property value.
2. If none of the vetoable change listeners has thrown a
PropertyVetoException, then update the value of the property.
3. Notify the property change listeners to confirm that a change has
occurred.

So I would have written the setFoo method to look something like this:

public void setFoo(String newFoo) throws PropertyVetoException {
String oldFoo = getFoo();
fireVetoableChange("foo", oldFoo, newFoo); // give listeners a chance
to throw a PropertyVetoException
this.foo = newFoo; // update the value
firePropertyChange("foo", oldFoo, getFoo()); // notify listeners the
value has changed
}

Should the JavaDoc be corrected?

Bruce

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

Bruce Alspaugh schrieb:
>
> Should the JavaDoc be corrected?
>

yes - it's a semi-secret open issue

http://forums.java.net/jive/message.jspa?messageID=145483#145483

could you please file an issue (preferably with a patch)?

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net