[rules-users] Why no rule will be fired if class name and attribute name is same

Davide Sottara dsotty at gmail.com
Wed Oct 23 02:09:26 EDT 2013


MVEL fails at analyzing the condition input == "a", I suspect it
confuses "input" with "input.class",
which of course is different from the literal "a". The alpha constraint
is then reduced to "false",
and no rule will fire. An edge case, but a bug.

HOWEVER, I would recommend to follow the java best practices and naming
conventions.
"declare" is effectively defining a new class, so you should rename it
Input, which will also
avoid the problem.

Davide

On 10/22/2013 05:45 PM, richie wrote:
> declare input
> input : String
> end
>
> declare output
> taskname : String
> end
>
> rule "Rule A"
> dialect "mvel"
> salience 0
> no-loop
> when
> $input:input(input == "a")
> $output:output()
> then
> modify ($output) {taskname = "Hello"};
> end

But if I created a fact object of input and set attribute input to "a", it
did not fire any rules.



More information about the rules-users mailing list