You cannot access any variable declared between 'then' and 'end'. These are local in the same sense as a variable declared in a Java method.
For passing anything computed in a rule consequence to the embedding Java program you might * insert a Fact of some suitable type and retrieve this from the ksession using API methods, e.g., by running a query, or by calling Collection<Object> getObjects(ObjectFilter filter) ) * define a global and simply assign to it in the consequence, and retrieve it using ksession API Object getGlobal( String identifier ) -W On 13/07/2012, Ravikiran <ravikiran.kaka...@gmail.com> wrote: > Hi Drools Gurus, > > One more newbie here for Drools Guvnor. I have chosen > "guvnor-distribution-5.3.0.Final" (I could see version as SNAPSHOT 5.4.0 > within Guvnor-->Administration-->About) to start with. After reading > through > the complete user manual, I was able to setup and deploy Drools Guvnor war > in JBoss AS 7. > > My intension is to access all the rules that i have created using Guvnor > web. I have written a java test case to access my Rules which are resided > in > a drools Package using REST API. I was successful to access them using > standard Authentication mechanism with charset*.xml. Even though i was able > to call fireAllRules with specific rule using "AgendaFilter" provided. But > i > was not able to access the values at RHS after a specific rule got fired. > For Example, i want to access "percent value as 2.5" after the below sample > rule is successfully executed, > I have uploaded my model jar to Guvnor containing Person & LoanFormula > classes. > > ---Rule 1 (please do not see the syntax errors) > WHEN > Person age > 25 > ---- > THEN > LoanFormula percent = 2.5 > .... > .... > > JAVA Code follows > --------------------- > KnowledgeBase kbase = ... > FactType personType = kbase.getFactType( "org.drools.examples","Person" ); > Object bob = personType.newInstance(); > personType.set( bob, "name","Bob" ); > personType.set( bob,"age",42 ); > StatefulKnowledgeSession ksession = ... > ksession.insert( bob ); > AgendaFilter filter = new ......("Rule1"); > int count = ksession.fireAllRules(filter); > String name = personType.get( bob, "name" ); > int age = personType.get( bob, "age" ); > > It would be great help if some one can show me the sample code for > accessing > RHS part of the Rule. Please let me know if you need more details. > > thanks > Kiru > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-Access-Rule-RHS-THEN-Part-from-JAVA-tp4018651.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users