Much better now.....

Thanks.....
E

Wolfgang Laun wrote:
>
> Notice that updates via (call ....) to the Java object require that the
> bean does property change notification, as described in section 5.3.3,
> to update the shadow fact.
>
> ; class Host with attributes firstName, lastName
> (deftemplate Host (declare (from-class at.laune.project.Host)))
>
> (reset)
> (bind ?h1 (new at.laune.project.Host "John" "Smith"))
> (add ?h1)
> (bind ?h2 (new at.laune.project.Host "Paul" "Jones"))
> (add ?h2)
>
> (defrule find1
>     (declare (no-loop TRUE))
>     ?hostFact <- (Host (OBJECT ?hostObj) (lastName "Smith"))
>     =>
>     (printout t "fact 1 - firstName = " (fact-slot-value ?hostFact
> firstName) crlf)
>     (call ?hostObj setFirstName "George")
>     (printout t "fact 1 - firstName = " (fact-slot-value ?hostFact
> firstName) crlf)
> )
>
> (defrule find2
>     (declare (no-loop TRUE))
>     ?hostFact <- (Host (lastName "Jones"))
>     =>
>     (printout t "fact 2 - firstName = " (fact-slot-value ?hostFact
> firstName) crlf)
>     (modify ?hostFact (firstName "Richard"))
>     (printout t "fact 2 - firstName = " (fact-slot-value ?hostFact
> firstName) crlf)
> )
>
> (printout t "Java object 1 - firstName = " (call ?h1 getFirstName) crlf)
> (printout t "Java object 2 - firstName = " (call ?h2 getFirstName) crlf)
> (run)
> (printout t "Java object 1 - firstName = " (call ?h1 getFirstName) crlf)
> (printout t "Java object 2 - firstName = " (call ?h2 getFirstName) crlf)
>
>
> vanhaabe wrote:
>
>>Still no progress. Can't bind OBJECT, error I'm getting is "Undefined
>>function OBJECT".
>>Can you please elaborate to call "OBJECT" in cpl file.
>>
>>Thanks,
>>E
>>
>>Wolfgang Laun wrote:
>>
>>
>>>The object behind the shadow fact is available in the slot OBJECT.
>>>Simply bind that slot to a Jess variable:
>>>   (MC ... (OBJECT ?mcObj))
>>>   ---
>>>   (call ?mcObj setPassed TRUE)
>>>
>>>If MC is sufficiently beanish you have a slot Passed and can use modify
>>>with some variable bound to the fact which will update the Java object;
>>>but if you call the method: does it trigger the update of the shadow
fact?
>>>
>>>The Jess manual's section 5.3 contains more useful hints on shadow facts.
>>>-WL
>>>
>>>vanhaabe wrote:
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>This is probably easy onem, but I can't figure it out.  I need to do
>>>>
>>>>
>>object
>>
>>
>>>>validation, and have flag "passed" set from within my rule.
>>>>_________________________________________________________
>>>>This is my cpl file
>>>>(import com.mycompany.yadda.yadda.MC)
>>>>(deftemplate MC(declare (from-class MC)))
>>>>(defrule mcrule
>>>>   "Rule 11"
>>>>   (MC {fg == "P"})
>>>>   =>
>>>>   (printout t "Rule 11" crlf)
>>>>   (call ?MC setPassed TRUE)
>>>>)
>>>>_______________________________________________________________
>>>>
>>>>and this is how  I call it from Java:
>>>>engine.resetToMark(marker);
>>>>            MC mc = new MC();
>>>>       mc.setfg("P");
>>>>
>>>>       MC mc1 = new MC();
>>>>       mc1.setfg("D");
>>>>
>>>>
>>>>       engine.add(mc);
>>>>       engine.add(mc1);
>>>>
>>>>       engine.run();
>>>>       return engine.getObjects(new Filter.ByClass(MgmtChars.class));
>>>>_____________________________________________________________________
>>>>Rules are validated correctly, but when it executes method setPassed it
>>>>throws exceptions: "No such variable MC", and that is correct. I simply
>>>>don't know how to reference/access object that rule is currently
executed
>>>>on. If you can shed some light on it that would be really appreciated.
>>>>
>>>>Thanks,
>>>>Ed
>>>>--
>>>>View this message in context:
>>>>
>>>>
>>http://www.nabble.com/Jess-newbie-does-not-know-how-to-....-tp15837006p15837006.html
>>
>>
>>>>Sent from the Jess mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>>--------------------------------------------------------------------
>>>>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]
>>>>--------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>--------------------------------------------------------------------
>>>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]
>>>--------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>>
>>
>>--
>>View this message in context:
http://www.nabble.com/Jess-newbie-does-not-know-how-to-....-tp15837006p15853415.html
>>Sent from the Jess mailing list archive at Nabble.com.
>>
>>
>>--------------------------------------------------------------------
>>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]
>>--------------------------------------------------------------------
>>
>>
>>
>
>
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------
>
>
>

--
View this message in context: 
http://www.nabble.com/Jess-newbie-does-not-know-how-to-....-tp15837006p15857787.html
Sent from the Jess mailing list archive at Nabble.com.


--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to