Normally, slots in Jess templates are based on JavaBeans properties -- i.e., a method named "getInetModem" will give rise to a slot named "inetModem". If you include the "include-variables TRUE" declaration, then slots will also be created based on *public* member variables. Under no circumstances will Jess create slots based on private member variables.



On Aug 21, 2009, at 10:39 AM, Romain Van der Keilen wrote:

Here is the exact code I use:

(import be.uniway.rvk.jesstest.model.*)
(deftemplate VirtualSite        (declare (from-class VirtualSite)))
(deftemplate InetModem          (declare (from-class InetModem)))

(defrule validate-virtualsite
       "Just put the validate attribute to true!"
   ?inetModem <- (InetModem (publicIpAddress ?publicIpAddress))
                 (VirtualSite (inetModem ?inetModem))
   =>
   (printout t "Internet modem address: " ?publicIpAddress crlf)
)


Using:

VirtualSite
 + private InetModem inetModem

InetModem
 + private String publicIpAddress

Maybe the private fields are disturbing Jess?

Regards,

Romain Van der Keilen.



From: [email protected] [mailto:owner-jess- [email protected]] On Behalf Of Romain Van der Keilen
Sent: vendredi 21 août 2009 16:15
To: [email protected]
Subject: RE: JESS: Accessing Java objects fields from a defrule

Thanks for the response,

You've exactly put the finger on what I wish do, but I just tried that and I've no output :s

From: [email protected] [mailto:owner-jess- [email protected]] On Behalf Of Wolfgang Laun
Sent: vendredi 21 août 2009 15:41
To: [email protected]
Subject: Re: JESS: Accessing Java objects fields from a defrule

First, you bind to the contained object, and then you locate the containing object.

(defrule mydoor
  ?door <- (Door (weight ?weight)(color ?color))
                 (House (myDoor ?door)(owner "Mick"))
=>
  (printout t "Weight of Mick's door :" ?weight crlf)
)

Restrictions on weight or color, e.g., to paint red doors black ;-) can be added in the usual way.

-W
On Fri, Aug 21, 2009 at 12:12 PM, Romain Van der Keilen <[email protected] > wrote:
Hi there,

I have a little question for you I can't fix by myself: how to access the fields of a java Object that is itself a field of an other java object?
Here is a tiny sample :

Object Door
+ int weight
+ String color

Object House
+ Door myDoor

Now I give the House to the Rete engine, how can I access (and manipulate) for example the weight of my door?

By now I just can display it like this:
(defrule mydoor
  (House (myDoor ?myDoor))
  =>
  (printout t "Weight of my house's door :" ?myDoor.weight crlf)
)
But the thing I want to do is to catch that weight to make some checks on it, then displaying the checks' results (for examples, is my door heavier than 25kg).

Thanks for help

Romain Van der Keilen



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

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            [email protected]
Livermore, CA 94550                             http://www.jessrules.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