Hi!
(1) Did you define a dynamic or static Bean instance?
(2) Does your Bean's setName(String) method fire a PropertyChange event?
In order to have your shadow facts' slot values modified you need to (1) define
dynamic instances using
(definstance mybean (new MyBean ...)) or
(definstance mybean (new MyBean ...) dynamic)
and to (2) fire PropertyChange events in your setter methods. This is due to the way
the Definstance and Modify Userfunctions (i.e., the classes implementing (definstance
...) and (modify ...)) are working. Definstance creates a shadow fact and registers
itself as a PropertyChangeListener, if the Bean is dynamic. Modify doesn't change the
shadow fact's slot values directly. Instead, it uses the Set Userfunction in order to
modify the Bean's properties via its setter methods (using Reflection). The shadow
fact's slot value, which is printed by the (facts) statement, is changed by the
Definstance Userfunction only upon reception of a PropertyChangeEvent sent by the
Bean's setter method.
Thomas
> I am using (modify) to alter the value of a slot in a definstance
> fact which is mapped onto
> an instance of a bean.
>
> (defrule startup => (modify 1 (name "Emmeline")))
>
> The I try to print the value of the bean property inside the Java
> program and it displays
> fine. The funny thing is that before and after I print out the
> property, the use of (facts) shows
> the following output. The slot in the definstance fact is not
> changed! Why is this so?
>
> r.reset();
> r.executeCommand("(batch JessBean.clp)");
> r.run();
> r.executeCommand("(facts)");
> System.out.println(bean.getName());
> r.executeCommand("(facts)");
>
> Output:
>
> f-0 (initial-fact)
> f-1 (mybean (class <External-Address:java.lang.Class>) (name
> "Mimi") (OBJECT <
> External-Address:MyBean>))
> For a total of 2 facts.
> Emmeline
> f-0 (initial-fact)
> f-1 (mybean (class <External-Address:java.lang.Class>) (name
> "Mimi") (OBJECT <
> External-Address:MyBean>))
> For a total of 2 facts.
---------------------------------------------------------------------
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]
---------------------------------------------------------------------