Changed below; I forgot to change the draft I'd saved...<br><br><div class="gmail_quote">On 13 April 2011 17:37, Michael Anstis <span dir="ltr"><<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>></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'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've also removed the inline evals you were using.<div class="im"><br>
<br><span style="font-family: courier new,monospace;">rule "Rule1"</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 "mvel"</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 ("screen1.panel1.editbox1", "screen1.panel1.editbox2") )</b></span><br style="font-family: courier new,monospace;">
<div class="im"><span style="font-family: courier new,monospace;">
ad : ApplicationData( age == "" || ( == 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( "\n age should not be null or empty" );</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 "Rule2"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dialect "mvel"</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 == "screen1.panel1.editbox1" )</b></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
ad : ApplicationData( $age : age != null , age != "" , age < 0 || > 100, minIssrdAge == "Years" )</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( "\nage is out of the range(i.e. < 0 and > 100)" );</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 "Rule3"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
dialect "mvel"</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 == "screen1.panel1.editbox2" )</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 != "" , age <0 || > 600, minIssrdAge == "Years" )</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( "\nage is out of the range(i.e. < 0 and > 600)" );</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"><<a href="mailto:benson.redhat@gmail.com" target="_blank">benson.redhat@gmail.com</a>></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't find any solution by now.<br>
<br>
rule "Rule1"<br>
salience 1<br>
dialect "mvel"<br>
when<br>
ad : ApplicationData( age == "" || ( == null ))<br>
then<br>
ad.setReturnMsg( "\n age should not be null or empty" );<br>
end<br>
<br>
<br>
rule "Rule2"<br>
dialect "mvel"<br>
when<br>
ad : ApplicationData( $age : age != null , age != "" , minIssrdAge<br>
== "Years" )<br>
eval(Integer.parseInt($age) < 0) or eval(Integer.parseInt($age) > 100)<br>
then<br>
ad.setReturnMsg( "\nage is out of the range(i.e. < 0 and > 100)" );<br>
end<br>
<br>
rule "Rule3"<br>
dialect "mvel"<br>
when<br>
ad : ApplicationData( $age : age != null , age != "" , minIssrdAge<br>
== "Years" )<br>
eval(Integer.parseInt($age) < 0) or eval(Integer.parseInt($age) > 600)<br>
then<br>
ad.setReturnMsg( "\nage is out of the range(i.e. < 0 and > 600)" );<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>