Reputation: 5325
Below is my code regarding property change. If I use this code,
public void propertyChange(PropertyChangeEvent evt)
will be called properly.
public void setWeekDate(Date weekDate) {
firePropertyChange("weekDate", this.weekDate, this.weekDate = weekDate);
}
But if I use below code public void propertyChange(PropertyChangeEvent evt)
will not be
called.
public void setWeekDate(Date weekDate) {
this.weekDate = weekDate;
firePropertyChange("weekDate", this.weekDate, weekDate);
}
could anyone tell me whats wrong with the above code?
Upvotes: 1
Views: 232
Reputation: 2826
In the second instance, you provide the same value twice. I'm guessing firePropertyChange does nothing if the value didn't actually change. Try this:
public void setWeekDate(Date weekDate) {
Date oldValue = this.weekDate;
this.weekDate = weekDate;
firePropertyChange("weekDate", oldValue, this.weekDate);
}
Upvotes: 2