5 Replies Latest reply on Sep 7, 2007 5:41 AM by Pete Muir

    foo.page.xml <action execute=...> never fires. Why?

    steve tynor Novice

      JBoss AS 4.2.1, Seam 1.2.1-GA

      I am trying to use action-execute on a page.xml file to initialize my backing bean, but it's never being called. Can anyone explain what I need to do to get the page-action-execute to fire? (from my eyes, this is no different than a page.xml that successfully fires the wire() functions in my home classes).

      My home.page.xml:

      <!DOCTYPE page PUBLIC
       "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
       "http://jboss.com/products/seam/pages-1.2.dtd">
      <page login-required="true">
       <begin-conversation join="true"/>
       <action execute="#{dashboard.init}"/>
      </page>


      The page.xml is right next to the facelets source, just as seamgen does for its generated pages:

      view/home.xhtml
      view/home.page.xml


      Here's the bean. Ive tried both with and without @AutoCreate - it seems to make no difference.

      @Scope(ScopeType.SESSION)
      @AutoCreate
      @Name("dashboard")
      public class Dashboard implements Serializable {
      ...
       public void init() {
       log.info("In init");
      ...



        • 1. Re: foo.page.xml <action execute=...> never fires. Why?
          steve tynor Novice

          FWIW, I tried moving my page out of the top level of the web -- prompted by this thread (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=109752), to no effect. (I didn't expect it to help - after all, seamgen generates all its foo.page.xml files in the root of the view).

          Help?

          • 2. Re: foo.page.xml <action execute=...> never fires. Why?
            Dustin Norlander Apprentice

            You might also try :

            @Scope(ScopeType.SESSION)
            @Name("dashboard")
            public class Dashboard implements Serializable {
            ...
             @Create
             public void init() {
             log.info("In init");
            ...
            


            Which seems more likely what you want to do (otherwise you will call init every time that page is accessed).

            best,
            Dustin

            • 3. Re: foo.page.xml <action execute=...> never fires. Why?
              steve tynor Novice

              Ouch. I've debugged and found the problem. It turns out that the page is being initialized and then cached from a mention in pages.xml:

              <page view-id="/home.xhtml">
               <restrict>#{(not empty authenticator.currentClient)}</restrict>
               </page>


              Is this intentional? I'd have expected even views mentioned in pages.xml to load definitions out of foo.page.xml as well (with foo.page.xml overriding anything found in pages.xml). Is this behavior documented anywhere? The only mention I can find is in the reference manual where it just says:
              If you have a lot of different page actions and page parameters, or even just a lot of navigation rules, you will
              almost certainly want to split the declarations up over multiple files. You can define actions and parameters for
              a page with the view id /calc/calculator.jsp in a resource named calc/calculator.page.xml. The root
              element in this case is the <page> element, and the view id is implied:


              (no warning to avoid definitions in both foo.page.xml and pages.xml).

              I can work around by moving all the definitions from my foo.page.xml into pages.xml, but this feels error prone -- all of my restrict markup is in my pages.xml (most are wildcards, but a few pages are marked up explicitly), while most of my navigation and action markup is in foo.page.xml files -- until now I thought hey could all coexist. Now it would seem I need to choose one or the other...

              As others have commented recently, a Seam "best practices" guide would sure be a nice thing to have so that we don't all have to stumble on simple stuff like this and debug the innards of the framework to determine why it's not working like we think it ought to.



              • 4. Re: foo.page.xml <action execute=...> never fires. Why?
                Matt Drees Master

                Yeah, I agree that the documentation isn't clear that you shouldn't have two page definitions for a given view-id. There's a jira issue to warn the user if you try.

                I agree, it seems like a good idea to allow multiple definitions, with one taking priority over the others. I haven't thought about if there are any problems with doing this, though. Might be worth a jira issue.

                • 5. Re: foo.page.xml <action execute=...> never fires. Why?
                  Pete Muir Master

                  This (multiple overriding page definitions) has been requested before but never implemented satisfactorily http://jira.jboss.com/jira/browse/JBSEAM-1009 (well similar at least). I'll do Matt's JIRA over the next couple of days.