<br> Nikhil,<br><br> By your code snippet it is clear that you should not be declaring the pattern twice in your rule. You may want to fix that.<br> Also, you need to check that your code is correctly setting the values of the adultFare and childFare attributes, because if they are not correctly set, you will end up with a value of zero for them, that will make the rule to always fire. <br>
<br> If, after checking that, you still think it is a problem, please provide a self contained junit test case that shows your problem and I will investigate.<br><br> []s<br> Edson<br><br><br><div><span class="gmail_quote">2008/3/18, Nikhil_dev <<a href="mailto:k.nikhil@verchaska.com">k.nikhil@verchaska.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Hi,<br> Below is the code where i fire the Rule,<br> What i meant by "when i supply values to the above Rule" is,<br> In my application i have provided a place where user can enter values for<br> "Adult Fare", "Child Fare".... etc<br>
so i take the values from the and set it in a bean....(u can understand from<br> below code)<br> even if the user doesn't provide the values the Rule Still Executes....<br> While firing a Rule it (Drool) doesn't give any error for missing<br>
Values......<br> i hope u r getting what i am trying to say......<br> Waiting for a Reply.<br> <br> <code><br> try {<br> <br> final Reader sourceDRL = new StringReader(drlFileFormat);<br> // drlFileFormat is the String that contains the Dynamic Rule<br>
<br> final PackageBuilder builder = new PackageBuilder();<br> <br> //this wil parse and compile in one step<br> builder.addPackageFromDrl(sourceDRL);<br> <br> // Check the builder for errors<br>
if ( builder.hasErrors()){<br> System.out.println( builder.getErrors().toString() );<br> throw new RuntimeException("Unable to compile drl");<br> }<br>
<br> //get the compiled package (which is serializable)<br> final Package pkg = builder.getPackage();<br> <br> //add the package to a rulebase (deploy the rule package).<br> final RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
ruleBase.addPackage( pkg );<br> <br> final StatefulSession ruleStateSession =<br> ruleBase.newStatefulSession();<br> <br> ruleStateSession.addEventListener( new DebugAgendaEventListener()<br>
);<br> ruleStateSession.addEventListener( new<br> DebugWorkingMemoryEventListener() );<br> <br> ApplyRuleBean objApplyRuleBean = new ApplyRuleBean();<br> if(!_jtxtAdultfare.getText().isEmpty())<br>
objApplyRuleBean.setAdultFare(_jtxtAdultfare.getText());<br> if(!_jtxtChildfare.getText().isEmpty())<br> objApplyRuleBean.setChildFare(_jtxtChildfare.getText());<br> if(!_jtxtnettpayable.getText().isEmpty())<br>
<br> objApplyRuleBean.setNettPayable(_jtxtnettpayable.getText());<br> <br> /*Return "ruleStateSession" as a return type of the<br> function... for MultipleRule....*/<br> ruleStateSession.insert(objApplyRuleBean);<br>
<br> ruleStateSession.fireAllRules();<br> <br> ruleStateSession.dispose();<br> <br> int iIndexEquale = alActions.indexOf("=");<br> String sResultObject = (String)<br>
alActions.get(iIndexEquale-1);<br> <br> if(sResultObject.equalsIgnoreCase("Adult Fare")){<br> AppConstantsBean.getInstance().showErrorMessage("Result<br> Adult Fare ::::<br>
"+objApplyRuleBean.getAdultFare(),AppConstantsBean.INFO_MESSAGE);<br> System.out.println("Result adult fare ::::<br> "+objApplyRuleBean.getAdultFare());<br> }<br> if(sResultObject.equalsIgnoreCase("Child Fare")){<br>
AppConstantsBean.getInstance().showErrorMessage("Result<br> Child Fare ::::<br> "+objApplyRuleBean.getChildFare(),AppConstantsBean.INFO_MESSAGE);<br> System.out.println("Result child fare ::::<br>
"+objApplyRuleBean.getChildFare());<br> }<br> if(sResultObject.equalsIgnoreCase("Nett Payable")){<br> AppConstantsBean.getInstance().showErrorMessage("Result<br>
Nett Payable ::::<br> "+objApplyRuleBean.getNettPayable(),AppConstantsBean.INFO_MESSAGE);<br> System.out.println("Result nett payable ::::<br> "+objApplyRuleBean.getNettPayable());<br> }<br>
} catch (Throwable t) {<br> t.printStackTrace();<br> }<br> </code><br> <br><br> <br> <br> <br> <br> <br> <br> What do you mean by "when i supply values to the above Rule" ?<br> If you provide a snippet of the code you are using to assert objects<br>
into the working memory and/or the values of the objects you are asserting,<br> it may be easier to understand your problem.<br> It also does not seem right to declare the ApplyRuleBean pattern twice<br> as you are doing.<br>
<br> []s<br> Edson<br> <br> <br> <br>-----<br> Regards,<br> :working:Nikhil<br> <br>--<br> View this message in context: <a href="http://www.nabble.com/Missing-Values-for-a-Dymanic-Rule......-tp16091335p16114443.html">http://www.nabble.com/Missing-Values-for-a-Dymanic-Rule......-tp16091335p16114443.html</a><br>
<br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> </blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br>
Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>