9 Replies Latest reply on Mar 19, 2008 12:26 PM by Pete Muir

    h:commandLink not working inside s:fragment

    Martin Sznapka Newbie

      Hello


      Imagine simple page:


      <s:fragment rendered="#{hello.renderLink}">
        <h:commandLink action="#{hello.linkAction}" value="link"/>
      </s:fragment>
      



      with preloaded data:


      <page view-id="/home.xhtml" action="#{hello.loadPageData()}"/>
      



      and EVENT scoped bean:


      @Name("hello")
      @Scope(ScopeType.EVENT)
      public class Hello {
      
          private boolean renderLink = false;
      
          public void loadPageData() {
              renderLink = true;
          }
      
          public boolean getRenderLink() {
              return renderLink;
          }
      
          public void linkAction() {
              System.out.println("Hello: Link action");
          }
      }
      



      Result: The commandLink is not working (action linkAction() is not called)


      If you change


      private boolean renderLink = false;
      



      to


      private boolean renderLink = true;
      



      than everything works. Strange huh?


      It seems that the framework calls getRenderLink() before the loadPageData() and recognize: aha, the link will be not rendered, so I will disable it.


      For test: copy example files to jboss-seam-2.1.0.A1/examples/booking and deploy on jboss-4.2.2.GA.