Hello i have a problem with the design of a VetoableChangeListener:
I implement the VetoableChangeListener interface to listen changes of a property in a model class, when the model fires the
vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
i try to save the change in a DB, which could fail (by a SQLException, for example), if it fail's i throw an PropertyVetoException to revert changes in the model, but...
the model is delegating in a VetoableChangeSupport (JDK class), which when receive an PropertyVetoException catches it and notifies the revert to ALL the VetoableChangeListener ,with the oldValue/ newValue interchanged (later it rethrows the exception), so that the event comes to my class again and i try to save in DB again, etc...
I have an workarround which is the model NOT changes until nobody throw an PropertyVetoException, so that in the VetoableChangeListener i FIRST check if the data i going to save in DB is NOT equal to the data in the model, if it's equal i simply ignore the change.
Is there another better workaround?
P.D Sorry for my bad english