What you need is called &quot;inline eval expression&quot; (see the Drools Expert manual),<br>or an eval conditional element. The first one might be written as:<br><br>$c:Cheese(type == &quot;chedar&quot;, eval( this.existsInShop(&quot;shopName&quot;) ) )<br>
<br>-W<br><br><br><div class="gmail_quote">On Mon, Jan 4, 2010 at 12:49 PM, orchid <span dir="ltr">&lt;<a href="mailto:maya.pollack@gmail.com">maya.pollack@gmail.com</a>&gt;</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&#39;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 &quot;existsInShop&quot; from a rule:<br>
<br>
Rule &quot;Rule1&quot;<br>
  when<br>
    $c:Cheese(type == &quot;chedar&quot;, existsInShop &quot;shopName&quot;)<br>
  then<br>
    System.out.println(&quot;Rule1 is fired&quot;);<br>
end<br>
<br>
I get the compilation error: &quot;no viable alternative at input &quot;shopName&quot; in<br>
rule &quot;Rule1&quot; in pattern document&quot;. 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>