Everything is in the title of the question. Can you provide some use case we use PropertyChangeListener and VetoableChangeListener ?
Vetoable property changes. A VetoableChangeEvent for a constrained property should be fired before the actual value of the property has changed. This gives any VetoableChangeListener a chance to reject the change when its vetoableChange() method is called. The event source must catch the java.
A constrained property is a special kind of bound property. For a constrained property, the bean keeps track of a set of veto listeners. When a constrained property is about to change, the listeners are consulted about the change.
The main difference resides in the fact that PropertyChangeListener
are applied to bound properties while VetoableChangeListener
are applied to constrained properties.
A bound property is just a property, while a constrained property is a property on which listeners can express themselves about a change that is going to be made: they can refuse this change from happening.
What it actually happens is that when you notify a vetoable property change you will do something like
VetoableChangeSupport vcs;
vcs.fireVetoableChange(...);
and this can throw a PropertyVetoException
which will tell your bean that an observer wishes to block this property change (it should be rolled back).
A VetoableChangeListener can veto (forbid) the property change. It will be rolled back if the receiver wishes. You may also attach constraints to the changed property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With