Sure, whenever you copy values from your UI to your model for validation you also enter a fact representing the &quot;context&quot; of the values.<br><br>Using your example you have two edit boxes on one screen and your rule simply checks for the value of a single edit box; in this case the context differentiates the two.<br>
<br>Walking your example:<br><br>(1) When editbox 1 looses focus you copy the value from the dropdown and edit box 1 into your model, plus you enter a &quot;context&quot; fact stating that these values relate to that part of the UI (say &quot;screen1.panel1.editbox1&quot;). You then insert these facts into WM and call fireAllRules. The rules check the &quot;context&quot; and only execute if the values are for the (rule) applicable context. (2) Editbox 2 works in a similar way, but has a different context ((say &quot;screen1.panel1.editbox2&quot;).<br>
<br>Have a look at Plugtree - I believe they&#39;re quite well customed to writing UIs backed with rules; salaboy or esteban (or IRC #drools) might be able to offer more practical advice.<br><br>With kind regards,<br><br>
Mike<br><br><br><br><div class="gmail_quote">On 13 April 2011 17:48, Benson Fung <span dir="ltr">&lt;<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Michael,<br>
<br>
Can you elaborate more for the uses of the ApplicationContext?  I<br>
can&#39;t follow its uses.<br>
<br>
<br>
Thanks<br>
Benson<br>
<br>
2011/4/14 Michael Anstis &lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Here&#39;s a quick (and probably sub-optimal way) ;)<br>
&gt;<br>
&gt; When you copy values from the UI to Facts for validation you also include<br>
&gt; the context of the validation.<br>
&gt;<br>
&gt; I&#39;ve also removed the inline evals you were using.<br>
&gt;<br>
&gt; rule &quot;Rule1&quot;<br>
&gt;   salience 1<br>
&gt;   dialect &quot;mvel&quot;<br>
&gt;     when<br>
&gt;       ApplicationContext( context == &quot;*&quot; )<br>
&gt;       ad : ApplicationData( age == &quot;&quot; || (  == null ))<br>
&gt;     then<br>
&gt;       ad.setReturnMsg( &quot;\n age should not be null or empty&quot; );<br>
&gt; end<br>
&gt;<br>
&gt; rule &quot;Rule2&quot;<br>
&gt;   dialect &quot;mvel&quot;<br>
&gt;     when<br>
&gt;       ApplicationContext( context == &quot;screen1.panel1.ed&quot; )<br>
&gt;       ad : ApplicationData( $age : age != null , age != &quot;&quot; , age &lt; 0 || &gt;<br>
&gt; 100, minIssrdAge == &quot;Years&quot; )<br>
&gt;     then<br>
&gt;       ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 100)&quot; );<br>
&gt; end<br>
&gt;<br>
&gt; rule &quot;Rule3&quot;<br>
&gt;    dialect &quot;mvel&quot;<br>
&gt;      when<br>
&gt;        ad : ApplicationData( $age : age != null , age != &quot;&quot; , age &lt;0 || &gt;<br>
&gt; 600, minIssrdAge == &quot;Years&quot; )<br>
&gt;      then<br>
&gt;        ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 600)&quot; );<br>
&gt; end<br>
&gt;<br>
&gt; On 13 April 2011 17:19, Benson Fung &lt;<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; Here is the scenario :<br>
&gt;&gt;<br>
&gt;&gt; If there are 2 edit boxes and 2 dropdown list at the frontend like.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; dropdown(minIssrdAge1)   editbox(age1)<br>
&gt;&gt; dropdown(minIssrdAge2)   editbox(age2)<br>
&gt;&gt;<br>
&gt;&gt; everytime when I lost focus the editbox(age1 or age2),  the<br>
&gt;&gt; editbox(age1 or age2) value will be validated against the following<br>
&gt;&gt; rules.<br>
&gt;&gt; i.e.  minIssrdAge1 and age1 will be validated together if lost focus<br>
&gt;&gt; the editbox age1.<br>
&gt;&gt;       minIssrdAge2 and age2 will be validated together if lost focus<br>
&gt;&gt; the editbox age2<br>
&gt;&gt;<br>
&gt;&gt; Rule1 is mandatory because both editbox are required field.<br>
&gt;&gt; However, editbox(age1) is only valid within the 0 and 100.  and<br>
&gt;&gt; editbox(age2) is only valid within 0 and 600.<br>
&gt;&gt;<br>
&gt;&gt; In other words, editbox(age1) have to be validated against Rule1 +<br>
&gt;&gt; Rule2.  However, editbox(age2) have to validated against Rule1 +<br>
&gt;&gt; Rule3.<br>
&gt;&gt;<br>
&gt;&gt; My question, how to design the rule attribute or at the java program<br>
&gt;&gt; side so that different editbox can be validated against different<br>
&gt;&gt; rule.<br>
&gt;&gt;<br>
&gt;&gt; Please help.  I can&#39;t find any solution by now.<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Rule1&quot;<br>
&gt;&gt;        salience 1<br>
&gt;&gt;        dialect &quot;mvel&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                ad : ApplicationData( age == &quot;&quot; || (  == null ))<br>
&gt;&gt;        then<br>
&gt;&gt;                ad.setReturnMsg( &quot;\n age should not be null or empty&quot; );<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Rule2&quot;<br>
&gt;&gt;        dialect &quot;mvel&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                ad : ApplicationData( $age : age != null , age != &quot;&quot; ,<br>
&gt;&gt; minIssrdAge<br>
&gt;&gt; == &quot;Years&quot; )<br>
&gt;&gt;                eval(Integer.parseInt($age) &lt; 0) or<br>
&gt;&gt; eval(Integer.parseInt($age) &gt; 100)<br>
&gt;&gt;        then<br>
&gt;&gt;                ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt;<br>
&gt;&gt; 100)&quot; );<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Rule3&quot;<br>
&gt;&gt;        dialect &quot;mvel&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                ad : ApplicationData( $age : age != null , age != &quot;&quot; ,<br>
&gt;&gt; minIssrdAge<br>
&gt;&gt; == &quot;Years&quot; )<br>
&gt;&gt;                eval(Integer.parseInt($age) &lt; 0) or<br>
&gt;&gt; eval(Integer.parseInt($age) &gt; 600)<br>
&gt;&gt;        then<br>
&gt;&gt;                ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt;<br>
&gt;&gt; 600)&quot; );<br>
&gt;&gt; end<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<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>
</div></div></blockquote></div><br>