the old/new value is part of the PropertyChangeSupport spec, however
drools actually ignores all that, all it cares about is the source object:
public void propertyChange(final PropertyChangeEvent event) {
final Object object = event.getSource();
try {
FactHandle handle = getFactHandle( object );
if ( handle == null ) {
throw new FactException( "Update error: handle not found
for object: " + object + ". Is it in the working memory?" );
}
update( handle,
object );
} catch ( final FactException e ) {
throw new RuntimeDroolsException( e.getMessage() );
}
}
However do be aware that if you are asserting collections into drools
4.0.x you have some serious mutability issues, with regards to shadow
facts. Search for previous posts on this in core and dev and edson has
recently written a detailed blog on this at
http://blog.athico.com.
Andreas Langegger wrote:
hello,
when I have a bean and I want to use a property change listener for
collection members, how can I tell the listener the old state of the
collection?
This is the code for simple fields from the docs:
public void setState(final String newState) {
String oldState = this.state;
this.state = newState;
this.changes.firePropertyChange( "state",
oldState,
newState );
}
and now I want to hook in the firePropertyChange for the following
method which adds some elements to a set:
protected Set<Var> knownVariables = new HashSet<Var>();
public void addKnownVariable(String var) {
this.knownVariables.add(var);
changes.firePropertyChange("knownVariables", OLDSTATE??!,
knownVariables);
}
Will I have to copy the whole collection, switch the complete field
collection object that I can supply the "old state"?
thanks,
Andy
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users