I think Vikram Chhibber wrote:
> The code of my Item class goes like this....
If I remember correctly, your problem was that you were making dynamic
definstances of Item, but the shadow fact wasn't being updated when
an Item's properties changed.
>
> public void setItemName (String itemName) {
> this.itemName = itemName;
> }
...
> private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
> public void addPropertyChangeListener(PropertyChangeListener pcl) {
> pcs.addPropertyChangeListener(pcl);
> }
> public void removePropertyChangeListener(PropertyChangeListener pcl) {
> pcs.removePropertyChangeListener(pcl);
> }
> }
It's not enough to merely create the PropertyChangeSupport object and
supply the addPropertyChangeListener/ removePropertyChangeListener
methods; you also have to use the actually pcs object to send
notifications when your properties change -- that's the whole
idea. Here's a correct implementation of setItemName:
public void setItemName(String newItemName) {
String oldItemName = itemName;
itemName = newItemName;
pcs.firePropertyChange("itemName", oldItemName, newItemName);
}
You should write all of your setXXX methods this way.
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------