[rules-users] How to obtain the object/fact created in the rule file?

Benson Fung benson.redhat at gmail.com
Fri Jan 28 12:39:18 EST 2011


ok, do you mean it is like :

global FieldResults frs
 rule "Rule1"
           dialect "mvel"
           when
               Fields( field1 > "100" )
           then
               frs.setField1("This is Correct!")
   end

In the java file :

Fields fs = new Fields();
fs.setField1(100);
FieldResults frs = new FieldResults();
sf.insert(fs);
sf.insert(frs);
sf.fireAllRules();

right?

2011/1/29 Esteban Aliverti <esteban.aliverti at gmail.com>:
> One thing you can do is to define a global to store that object. Then you
> could retrieve it from the outside.
> Best,
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Developer @ http://www.plugtree.com
> - Blog @ http://ilesteban.wordpress.com
>
>
> On Fri, Jan 28, 2011 at 2:02 PM, Benson Fung <benson.redhat at gmail.com>
> wrote:
>>
>> Hi,
>>
>> I developed a rule as below:
>>
>>        rule "Rule1"
>>            dialect "mvel"
>>            when
>>                Fields( field1 > "100" )
>>            then
>>                FieldResults fact0 = new FieldResults();
>>                fact0.setField1( "This is Correct!" );
>>                insert(fact0 );
>>        end
>>
>> After calling fireAllRules(...), the above rule will be fired and
>> created a fact object in the working memory.
>> My problem is how to obtain the FieldResults object in the java
>> program.  Please advise.
>>
>>
>> Thanks
>> Benson
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>




More information about the rules-users mailing list