What you need is called "inline eval expression" (see the Drools Expert manual),<br>or an eval conditional element. The first one might be written as:<br><br>$c:Cheese(type == "chedar", eval( this.existsInShop("shopName") ) )<br>
<br>-W<br><br><br><div class="gmail_quote">On Mon, Jan 4, 2010 at 12:49 PM, orchid <span dir="ltr"><<a href="mailto:maya.pollack@gmail.com">maya.pollack@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi All,<br>
<br>
I'm trying to call a class method from the LHS of a rule in the following<br>
way:<br>
<br>
public class Cheese{<br>
private string type;<br>
//setters and getters<br>
public boolean existsInShop(String shop){<br>
...<br>
return true;<br>
}<br>
}<br>
<br>
I would like to call the method "existsInShop" from a rule:<br>
<br>
Rule "Rule1"<br>
when<br>
$c:Cheese(type == "chedar", existsInShop "shopName")<br>
then<br>
System.out.println("Rule1 is fired");<br>
end<br>
<br>
I get the compilation error: "no viable alternative at input "shopName" in<br>
rule "Rule1" in pattern document". How can I call the method from the rule?<br>
<br>
Thanks in advance.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
View this message in context: <a href="http://n3.nabble.com/Call-class-method-from-LHS-of-a-rule-tp108383p108383.html" target="_blank">http://n3.nabble.com/Call-class-method-from-LHS-of-a-rule-tp108383p108383.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>