What is the difference between PropertyChangeListener and VetoableChangeListener?

Everything is in the title of the question. Can you provide a usage example that we use PropertyChangeListener and VetoableChangeListener?

+6
java
source share
2 answers

The main difference is that PropertyChangeListener applied to related properties, and VetoableChangeListener applied to restricted properties.

A related property is simply a property, while a limited property is a property on which listeners can express themselves about the change that will be made: they can reject the change.

What actually happens is that when you notify you of a change in veto rights, you will do something like

 VetoableChangeSupport vcs; vcs.fireVetoableChange(...); 

and this may raise a PropertyVetoException , which tells your bean that the observer wants to block this property change (it must be rolled back).

+8
source share

An adherent of a veterinary change may veto (prohibit) a change in property. It will be rolled back if the receiver wishes. You can also apply restrictions to the changed property. http://java.sun.com/j2se/1.4.2/docs/api/java/beans/VetoableChangeListener.html

+1
source share

All Articles