Changed below; I forgot to change the draft I&#39;d saved...<br><br><div class="gmail_quote">On 13 April 2011 17:37, Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@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;">Here&#39;s a quick (and probably sub-optimal way) ;)<br><br>When you copy values from the UI to Facts for validation you also include the context of the validation.<br>
<br>I&#39;ve also removed the inline evals you were using.<div class="im"><br>
<br><span style="font-family: courier new,monospace;">rule &quot;Rule1&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  salience 1</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  dialect &quot;mvel&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    when</span><br style="font-family: courier new,monospace;">

</div><span style="font-family: courier new,monospace;">      <b>ApplicationContext( context in (&quot;screen1.panel1.editbox1&quot;, &quot;screen1.panel1.editbox2&quot;) )</b></span><br style="font-family: courier new,monospace;">
<div class="im"><span style="font-family: courier new,monospace;">

       ad : ApplicationData( age == &quot;&quot; || (  == null ))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
     then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
       ad.setReturnMsg( &quot;\n age should not be null or empty&quot; );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
rule &quot;Rule2&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  dialect &quot;mvel&quot;</span><span style="font-family: courier new,monospace;"><br>    when</span><br style="font-family: courier new,monospace;">

</div><span style="font-family: courier new,monospace;">
       <b>ApplicationContext( context == &quot;screen1.panel1.editbox1&quot; )</b></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">


       ad : ApplicationData( $age : age != null , age != &quot;&quot; , age &lt; 0 || &gt; 100, minIssrdAge == &quot;Years&quot; )</span><div class="im"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    then</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">
       ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 100)&quot; );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
rule &quot;Rule3&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  
 dialect &quot;mvel&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
      when</span><br style="font-family: courier new,monospace;"></div><span style="font-family: courier new,monospace;">
 </span><span style="font-family: courier new,monospace;">
        <b>ApplicationContext( context == &quot;screen1.panel1.editbox2&quot; )</b></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">


 </span><span style="font-family: courier new,monospace;">       ad : ApplicationData( $age : age != null , age != &quot;&quot; , age &lt;0 || &gt; 600, minIssrdAge == &quot;Years&quot; )</span><div class="im"><span style="font-family: courier new,monospace;">     then</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">
        ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 600)&quot; );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br></div><div><div></div><div class="h5"><div class="gmail_quote">On 13 April 2011 17:19, Benson Fung <span dir="ltr">&lt;<a href="mailto:benson.redhat@gmail.com" target="_blank">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,<br>
<br>
Here is the scenario :<br>
<br>
If there are 2 edit boxes and 2 dropdown list at the frontend like.<br>
<br>
<br>
dropdown(minIssrdAge1)   editbox(age1)<br>
dropdown(minIssrdAge2)   editbox(age2)<br>
<br>
everytime when I lost focus the editbox(age1 or age2),  the<br>
editbox(age1 or age2) value will be validated against the following<br>
rules.<br>
i.e.  minIssrdAge1 and age1 will be validated together if lost focus<br>
the editbox age1.<br>
       minIssrdAge2 and age2 will be validated together if lost focus<br>
the editbox age2<br>
<br>
Rule1 is mandatory because both editbox are required field.<br>
However, editbox(age1) is only valid within the 0 and 100.  and<br>
editbox(age2) is only valid within 0 and 600.<br>
<br>
In other words, editbox(age1) have to be validated against Rule1 +<br>
Rule2.  However, editbox(age2) have to validated against Rule1 +<br>
Rule3.<br>
<br>
My question, how to design the rule attribute or at the java program<br>
side so that different editbox can be validated against different<br>
rule.<br>
<br>
Please help.  I can&#39;t find any solution by now.<br>
<br>
rule &quot;Rule1&quot;<br>
        salience 1<br>
        dialect &quot;mvel&quot;<br>
        when<br>
                ad : ApplicationData( age == &quot;&quot; || (  == null ))<br>
        then<br>
                ad.setReturnMsg( &quot;\n age should not be null or empty&quot; );<br>
end<br>
<br>
<br>
rule &quot;Rule2&quot;<br>
        dialect &quot;mvel&quot;<br>
        when<br>
                ad : ApplicationData( $age : age != null , age != &quot;&quot; , minIssrdAge<br>
== &quot;Years&quot; )<br>
                eval(Integer.parseInt($age) &lt; 0) or eval(Integer.parseInt($age) &gt; 100)<br>
        then<br>
                ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 100)&quot; );<br>
end<br>
<br>
rule &quot;Rule3&quot;<br>
        dialect &quot;mvel&quot;<br>
        when<br>
                ad : ApplicationData( $age : age != null , age != &quot;&quot; , minIssrdAge<br>
== &quot;Years&quot; )<br>
                eval(Integer.parseInt($age) &lt; 0) or eval(Integer.parseInt($age) &gt; 600)<br>
        then<br>
                ad.setReturnMsg( &quot;\nage is out of the range(i.e.  &lt; 0 and &gt; 600)&quot; );<br>
end<br>
<div><div></div><div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</div></div></blockquote></div><br>