Feature Requests item #682592, was opened at 2003-02-07 23:19
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=428711&aid=682592&group_id=40712
Category: codegen
Group: None
Status: Open
Priority: 5
Submitted By: Max R. Andersen (maxcsaucdk)
Assigned to: Max R. Andersen (maxcsaucdk)
Summary: Have hbm2java generate support for veto and change listeners
Initial Comment:
How about adding somemore JavaBeans Functionality,
namely the PropertyChange- and
VetoableChangeMechanism.
I envision something like
<property ... changeType="[bound|constraint]" />
which would lead to the incorporation of the appropriate
SupportClass and the Eventfiring code to the setter
Methods.
Specifically I am refering to
1) the hibernate codegenerator
2) JavaBeans Spec. 1.0.1 Sect. 7.4
Thus the SupportClass is given by the appropriate classes
in the beans package;
the code should look somewhat like this:
import java.awt.*;
import java.beans.*;
public class JellyBean {
public Color getColor() {
return ourColor;
}
public void setColor(Color newColor) {
Color oldColor = ourColor;
ourColor = newColor;
changes.firePropertyChange( color , oldColor, newColor);
}
public int getPriceInCents() {
return ourPriceInCents;
}
public void setPriceInCents(int newPriceInCents) throws
PropertyVetoException {
int oldPriceInCents = ourPriceInCents; // First tell the
vetoers about the change. If anyone objects, we
// let the PropertyVetoException propagate back to our
caller.
vetos.fireVetoableChange( priceInCents , new
Integer(oldPriceInCents), new Integer(newPriceInCents));
// No one vetoed, so go ahead and make the change.
ourPriceInCents = newPriceInCents;
changes.firePropertyChange( priceInCents , new
Integer(oldPriceInCents), new Integer(newPriceInCents));
}
public void
addPropertyChangeListener(PropertyChangeListener l) {
changes.addPropertyChangeListener(l);
}
public void
removePropertyChangeListener(PropertyChangeListener l)
{
changes.removePropertyChangeListener(l);
}
public void
addVetoableChangeListener(VetoableChangeListener l) {
vetos.addVetoableChangeListener(l);
}
public void
removeVetoableChangeListener(VetoableChangeListener l)
{
vetos.removeVetoableChangeListener(l);
}
private PropertyChangeSupport changes = new
PropertyChangeSupport(this);
private VetoableChangeSupport vetos = new
VetoableChangeSupport(this);
private Color ourColor = Color.orange;
private int ourPriceInCents = 2;
}
See
https://sourceforge.net/forum/forum.php?thread_id=8097
53&forum_id=128638
for the glory details :)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=428711&aid=682592&group_id=40712
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel