7 Replies Latest reply on Sep 18, 2006 7:37 PM by gavin.king

    Problem with extra action method executing

    texan

      I keep having trouble where the "from" page action seems be getting executed when using the <s:link> tag. Here's one example:

      Page "one.xhtml" has a pages.xml entry with an action defined, so that the action gets called whenever I view "one.xhtml" (actionOne.load()).

      There's an <s:link> on one.xhtml that goes to "actionTwo.search" (which goes to "two.xhtml").

      When I click the link, the actionOne.load() method is being invoked AFTER actionTwo.search().

      1. I don't want it to be invoked at all, I'm just trying to go to actionTwo.search()

      2. Why the heck would it be invoked after actionTwo.search()?

        • 1. Re: Problem with extra action method executing
          sjmenden

          Just to let you know, you are not alone. I am not sure if there is some special attribute to the pages.xml xml, however, I ran into the exact same problem. Lessoned learned, don't use pages.xml with a Stateful bean that uses pagination, it won't work. I had to change the way I was doing things because I believe what you described above is intended by the pages.xml action. You define pages there so that the corresponding action gets executed EVERY time the page is loaded without exception.

          If this breaks your application, then you shouldn't use pages.xml, but look at the @Factory method possibly. Or the pull-style section of the seam documentation.

          • 2. Re: Problem with extra action method executing
            texan

            My particular problem is that the "from" page action is getting executed when I leave the page. Very frustrating.

            • 3. Re: Problem with extra action method executing
              raja05

              This seems to be happening in AbstractPhaseListener and looks like a bug. The code in question is

               public boolean callPageActions(PhaseEvent event)
               {
               Lifecycle.setPhaseId( PhaseId.INVOKE_APPLICATION );
               boolean actionsWereCalled = false;
               try
               {
               actionsWereCalled = Pages.callAction( event.getFacesContext() ) || actionsWereCalled;
               actionsWereCalled = Pages.instance().callAction() || actionsWereCalled;
               return actionsWereCalled;
              

              The first "Pages.callAction(event.getFacesContext()) || actionsWereCalled " runs the intended action i.e. the action in the second page. Note that at this point, the view-id is still the first page as the lifecycle has not come into the "render" phase -- still in the "Execute" phase. Now that the method returned true, we are again invoking the Pages.instance().callAction() which calls the first view since the view-id is the first page. Thats the reason for the out of order of messages.

              If the code were
               actionsWereCalled = Pages.callAction( event.getFacesContext() ) || actionsWereCalled;
               actionsWereCalled = actionsWereCalled || Pages.instance().callAction();
               return actionsWereCalled;
              

              that should fix this.


              • 4. Re: Problem with extra action method executing
                texan

                Thanks for tracking down the source of the problem! I've been juggling too many projects to dare digging into the Seam code.

                I'll have to look into submitting this via JIRA.

                • 5. Re: Problem with extra action method executing
                  gavin.king

                  Please submit this to JIRA and I will take a look.

                  • 6. Re: Problem with extra action method executing
                    texan
                    • 7. Re: Problem with extra action method executing
                      gavin.king

                      I reviewed this and I can't confirm your conclusions. Make sure you have testes against current CVS. If it still doesn't work, I need a test case.