2 Replies Latest reply on Feb 13, 2007 2:26 PM by saeediqbal1

    Rules and navigation

    statelessbean

      Hi all,
      I'm newbie in seam...
      I want to use drools and rules in my seam pages but i dont understand how and where are used those roles.

      can anyone give me link or post me litle example how to use those drools?
      On doc files i found somethink like this:

      <page view-id="/editDocument.xhtml">
      
       <navigation from-action="#{documentEditor.update}">
       <rule if="#{documentEditor.errors.empty}">
       <end-conversation/>
       <render view-id="/viewDocument.xhtml"/>
       <rule/>
       </navigation-case>
      
      </navigation-rule>
      


      if my undestanding is well here we use rule, but what how? and where is "name" of those rule?

      I understand little bit rules but i still have problems with implementation in code and don't know where are they used (in source code) and in with cases.
      Stateless Bean



        • 1. Re: Rules and navigation
          saeediqbal1

          I would suggest go ahead and open the source code. Look into the resources folder and you will see a file called numberguess.drl . Examine that and then look at the source code.

          Contents are

          package org.jboss.seam.example.numberguess

          import org.jboss.seam.drools.Decision

          global Decision decision

          rule High
          when
          RandomNumber(randomValue:value)
          Guess(guess: value>randomValue)
          game: GameHistory()
          then
          game.setBiggest(guess.intValue()-1);
          end

          rule Low
          when
          RandomNumber(randomValue:value)
          Guess(guess: value<randomValue)
          game: GameHistory()
          then
          game.setSmallest(guess.intValue()+1);
          end

          rule Win
          when
          RandomNumber(randomValue:value)
          Guess(value==randomValue)
          then
          decision.setOutcome("win");
          end

          rule Lose
          when
          GameHistory(guessCount==9)
          then
          if ( decision.getOutcome()==null )
          {
          decision.setOutcome("lose");
          }
          end

          rule Incremement
          salience -10
          when
          game: GameHistory()
          then
          game.incrementGuessCount();
          end





          Also look at the file next to it called pageflow.jpdl.xml . I'm not putting contents for that here though :)

          Then feel free to ask specific questionsa bout functionality of seam+drools int hat application. once you have that implementation down, you'ld be ok to start your own seam+drools project

          • 2. Re: Rules and navigation
            saeediqbal1

            oh Mr. Bean i forgot to say the above stuff was the seam(distribution)/examples/drools/ . I learned the functionality from that example, which is pretty good. Personally i'm not using drools for now. Dont want to get tangled into alot of new stuff.