24.9. Pet Store Example: Doing the Checkout Extract from PetStore.drl

rule "do checkout"
    dialect "java"
    when
    then
        doCheckout(frame, drools.getWorkingMemory());
end
  • The rule "do checkout" has no agenda group set and no auto-focus attribute. As such, it is deemed part of the default (MAIN) agenda group. This group gets focus by default when all the rules in agenda-groups that explicitly had focus set to them have run their course.
  • There is no LHS to the rule, so the RHS will always call the doCheckout() function.
  • When calling the doCheckout() function, the rule passes the global frame variable to give the function a handle to the Swing GUI.
  • The doCheckout() function shows a confirmation dialog to the user. If confirmed, the function sets the focus to the checkout agenda-group, allowing the next lot of rules to fire.