<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br>Thanks for the insight,<br>br,<br>Els<br><br>--- On <b>Wed, 11/9/11, Wolfgang Laun <i>&lt;wolfgang.laun@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Wolfgang Laun &lt;wolfgang.laun@gmail.com&gt;<br>Subject: Re: [rules-users] variables confusion Java/MVEL<br>To: "Rules Users List" &lt;rules-users@lists.jboss.org&gt;<br>Date: Wednesday, November 9, 2011, 3:35 PM<br><br><div id="yiv1094698176">You cannot create variables on the Left Hand Side; there you can only bind (!)<br>variable names (!) to matched facts or their attributes.<br>-W <br><br><div class="yiv1094698176gmail_quote">On 9 November 2011 15:14, elsdestickere <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:elsdestickere@yahoo.com" target="_blank"
 href="/mc/compose?to=elsdestickere@yahoo.com">elsdestickere@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="yiv1094698176gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
I'm confused about when en where to use Java or MVEL in a rule.<br>
In the example below I want to replace &nbsp;"<br>
openRes.getMasterExemplaar().getBruikbareExemplaren()" with a variable.<br>
RHD: works with JAva expression:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Exemplaar&gt; bruikEx =<br>
openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
but I prefer to create the variable in the LHS, but Java doesn't work here.<br>
Should this be a MVEL expression or should JAVA allways be possible?<br>
<br>
rule "GarandeerReservaties"<br>
 &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp;garRes : GarandeerReservatieTaak();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;openRes : Reservatie() from<br>
repFact.getReservatieRepository().findVandaagOpenstaandeReservaties();<br>
 &nbsp; &nbsp; List&lt;Exemplaar&gt; bruikEx<br>
=openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
 &nbsp; &nbsp; &nbsp; eval(Reservatie.getVandaagOpenstaandeReservaties().size() &gt; 0 &amp;&amp;<br>
openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0)<br>
 &nbsp; &nbsp;then<br>
 &nbsp; &nbsp; &nbsp; &nbsp;//List&lt;Exemplaar&gt; bruikEx =<br>
openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bruikEx.get(0).setStatus(ExemplaarStatus.MOMENTEEL_GERESERVEERD);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;openRes.setStatus(ReservatieStatus.GEGARANDEERD);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;System.out.println( "Drools "+drools.getRule().getName()+": ocr:<br>
"+openRes.getAantalVandaagOpenstaandeConcurReservaties() + " bruikex: "<br>
+bruikEx.size() );<br>
end<br>
(written in Dutch, but I think it will be ok to understand)<br>
br,<br>
Els<br>
<font color="#888888"><br>
--<br>
View this message in context: <a rel="nofollow" target="_blank" href="http://drools.46999.n3.nabble.com/variables-confusion-Java-MVEL-tp3493632p3493632.html">http://drools.46999.n3.nabble.com/variables-confusion-Java-MVEL-tp3493632p3493632.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=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></div></blockquote></td></tr></table>