[rules-users] How to pass variables to a drools rule file?
Wolfgang Laun
wolfgang.laun at gmail.com
Wed Feb 27 03:56:50 EST 2013
This is yet another MVEL bug, as it appears to fail to handle package
visibility correctly.
Put Qos into a .java file of its own in any package, precede class by
"public" and use a proper import in the .drl.
You can omit the import if the package of the Java class and the .drl
is the same.
-W
On 27/02/2013, FrankVhh <frank.vanhoenshoven at agserv.eu> wrote:
> It is looking for com.sample.Qos. Try to add the import statement
> test.java.Qos somewhere on top of your file.
>
> Regards,
> Frank
>
>
> penny wrote
>> Hi,there.I have a class in test.java file.It looks like:
>> class Qos{
>> boolean S;
>> boolean W;
>> Qos(){
>> S = true;
>> W = false;
>> }
>> public boolean getS(){
>> return S;
>> }
>> public boolean getW(){
>> return W;
>> }
>> }
>>
>> Now I want to use the Qos class in my rule file like this:
>> rule "rule1"
>> ruleflow-group "myRules"
>> salience 4
>> when
>> //conditions
>> $qos:Qos(S==true && W==true);
>> then
>> System.out.println("rule1");
>> end
>>
>> But here is an error.
>> [Error: could not access field: com.sample.Qos.S]
>> [Near : {... S == true ....}]
>> ^
>> [Line: 1, Column: 1]
>>
>> How can I do?
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-pass-variables-to-a-drools-rule-file-tp4022607p4022608.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> 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