Given that you’re using Spring MVC, this might be a reasonable example:

https://github.com/gratiartis/sctrcd-payment-validation-web

It has examples of doing this for a simple validation, with a stateless session.

i.e.
  1. Request goes to Spring MVC controller.
  2. Controller invokes a service bean, which wraps a knowledge base.
  3. Rule based validator inserts a fact and executes rules.
  4. Rules may or may not set an ‘isValid’ flag on the request. They may (or may not) also annotate that request fact to indicate which rules are rejecting it and why.
  5. The rule based validator returns a result object to the service.
  6. The service returns a result object to the controller.
  7. The controller returns a JSON object to the client.

Hopefully it’s not too difficult to find your way around the project.

To try it out:
  1. git clone https://github.com/gratiartis/sctrcd-payment-validation-web
  2. cd sctrcd-payment-validation-web
  3. mvn clean install tomcat7:run
  4. curl http://localhost:9090/iban/validate/GB29NWBK60161331926819
  5. Change a couple of characters in the IBAN on another curl to see a rejection.

btw - If anybody else fancies taking a look at it, please feel free to send criticism back to me. Either directly or to discuss on the mailing list. There’s so little out there in the way of documented good practice for using Drools, that I get the impression that everyone just finds their own way. So I would be happy to hear what others feel could be done to improve my little Spring MVC/Drools demo project.

Steve


On 9 Nov 2013, at 09:24, forsakendoll <forsakendoll@hotmail.com> wrote:

I'm very new to drools. I know this question is really a noob question but
please bear with me. I'm using Spring MVC and I want to integrate drools
expert to my project. What I've done so far is to integrate the hello world
sample of drools expert. But now what I want to do is:

1. Send a bean to the rules for it to evaluate.
2. Modify the bean depending on the rules
3. Send it back to the controller to make a response to the user.

I was able to do the number 1. But for number 2 and 3. I don't know how to
do it. I want to have a nested rule. But now I'm only capable of doing this
rule:

global String $test;

rule "Excellent"

   when
       $m: FLTBean ( listeningScore > 85 )
       $p: FLTBean ( listeningScore < 101 )
   then
       $test = "Excellent";
       System.out.println( $test );

end

I don't know yet how can I make a nested rule. Please give me a simple
example that a newbie like me can understand.




--
View this message in context: http://drools.46999.n3.nabble.com/Drools-in-a-web-application-tp4026704.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