Hi Everyone:
I am starting to experiment with creating GUI using jess. In this simple
example, I am attempting to create a frame with two buttons and when the user
clicks on a button, I want to fire a rule. When a button is clicked, the
actionlistener calls the deffunction which asserts a fact. This fact should
cause the LHS of a rule to be satisfied and consequently fire that rule.
The RHS of the rule is just a printout to the standard output device.
When I execute the example, the frame and the buttons come up fine. When I
click on a button, the corresponding deffunction gets executed which
printsout the message "Clicked on Button One" or "Clicked on Button Two".
However, the rule is not getting fired. Since the message "Fired the
first rule" or "Fired the second rule" does not show up on the console, I
am assuming that the rules are not getting fired.
I am not clear on how to set up the actionlisteners to fire rules and do
some processing and then provide some feedback to the user. I also have a
couple of other questions. Is there some thing in jess equivalent to
"agenda" where we can see which rules have their LHS satisfied? Also, is
there a easy way to debug the application in jess?
Forgive me if these types of questions have already been answered. I am
very new to jess. I would greatly appreciate any help. Thanks.
Regards,
Vijayan Sugumaran
Le Moyne College
--------------------------------
example that I am working with:
(defglobal ?*f* = 0)
(defglobal ?*b1* = 0)
(defglobal ?*b2* = 0)
(bind ?*f* (new java.awt.Frame "Initial Panel"))
(set ?*f* layout (new java.awt.GridLayout 2 1))
(bind ?*b1* (new java.awt.Button "View Domain Model"))
(bind ?*b2* (new java.awt.Button "Specify Requirements"))
(?*f* add ?*b1*)
(?*f* add ?*b2*)
(?*f* pack)
(?*f* show)
(?*b1* addActionListener
(new jess.reflect.ActionListener button-one (engine)))
(?*b2* addActionListener
(new jess.reflect.ActionListener button-two (engine)))
(deffunction button-one (?evt)
(printout t "Clicked on Button One" crlf)
(assert (Clicked on Button One)))
(deffunction button-two (?evt)
(printout t "Clicked on Button Two" crlf)
(assert (Clicked on Button Two)))
;fire a rule
(defrule fire-one
(Clicked on Button One)
=>
(printout t "Fired the first rule" crlf))
(defrule fire-two
(Clicked on Button Two)
=>
(printout t "Fired the second rule" crlf))
(reset)
(run)
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------