Consider the following code:
import jess.*;
public class try10 implements JessListener
{
public void eventHappened(JessEvent je) throws JessException
{
int type = je.getType();
switch(type)
{
case JessEvent.DEFRULE_FIRED:
String ruleask="MAIN::ask-decision-node-question";
String s=((Activation) je.getObject()).getRule().getName();
if(s.equals(ruleask))
{
/* HERE I NEED TO EXECUTE THE RHS OF THE FIRED RULE MAIN::ask-decision-node-question */
}
break;
default: //ignore
}
}
public static void main(String args[])
{
try
{
Rete r=new Rete();
r.addJessListener(new try10());
r.setEventMask(r.getEventMask() | JessEvent.DEFRULE_FIRED );
.
.
.
r.executeCommand("(defrule ask-decision-node-question ?node <- (current-node ?name) (node (name ?name) (type decision) (question ?question)) (not (ans! wer ?)) =>
import jess.*;
public class try10 implements JessListener
{
public void eventHappened(JessEvent je) throws JessException
{
int type = je.getType();
switch(type)
{
case JessEvent.DEFRULE_FIRED:
String ruleask="MAIN::ask-decision-node-question";
String s=((Activation) je.getObject()).getRule().getName();
if(s.equals(ruleask))
{
/* HERE I NEED TO EXECUTE THE RHS OF THE FIRED RULE MAIN::ask-decision-node-question */
}
break;
default: //ignore
}
}
public static void main(String args[])
{
try
{
Rete r=new Rete();
r.addJessListener(new try10());
r.setEventMask(r.getEventMask() | JessEvent.DEFRULE_FIRED );
.
.
.
r.executeCommand("(defrule ask-decision-node-question ?node <- (current-node ?name) (node (name ?name) (type decision) (question ?question)) (not (ans! wer ?)) =>
/* TO BE EXECUTED IN THE EVENT HANDLER
(printout t ?question \" (yes or no) \") (assert (answer (read))) */
(printout t ?question \" (yes or no) \") (assert (answer (read))) */
)");
.
.
.
r.executeCommand("(reset)");
r.executeCommand("(run)");
}
catch(JessException jex)
{
System.err.println(jex);
}
}
}
As, specified in the above code, when the rule MAIN::ask-decision-node-question fires, i need to execute the RHS in the eventhandler and not in the main( ) method.
How can this be done?? Can u illustrate it in the form of an example???
Hoping to be obliged...
Monika
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
