I have to send some values from the Java class which calls the Jess script for processing in the Jess script.
This is my code till now:
int val1=0;
int val2=1;
Rete engine = new Rete();
Value val = engine.batch("abc.clp");
System.out.println("\n"+val);
engine.watchAll();
How do I pass the values val1
and val2
? I found this example but it did not help much.
A set of values from a dialog is best put into a POJO which is inserted into working memory and accessed via a deftemplate declared as being derived from a Java class. Using this in rules is straightforward. The POJO may also hold a field for storing results derived by rule firing.
The script should set up the Jess definitions but it should not call run. This is best done from Java and most certainly after the insert of the fact.
Below is a minimum example showing all of the aforesaid.
The POJO class:
The clp file, (modified to demonstrate how to access slot values, and added no-loop):