1 2 Previous Next 22 Replies Latest reply on Sep 14, 2011 9:44 AM by ionutbarau Go to original post
      • 15. Re: EL expression for id attributes?
        ziphyre

        I don't believe it!!!!:

        $('id_of_the_parent_div').getElementsByClassName('message_#{msg.id}')[0]

        • 16. Re: EL expression for id attributes?
          grimholtz

           

          it is resolved to null on what JSF lifecycle phase? 2nd or 6th?

          Sergey, I used a phase listener. The id isn't null in any phase. And this code works:

          <a4j:include viewId="/abc.xhtml" rendered="#{barBean.viewId=='abc'}"/>
          <a4j:include viewId="/def.xhtml" rendered="#{barBean.viewId=='def'}"/>


          It appears that only the viewId cannot be dynamic. Can you please confirm?

          Thanks.

          • 17. Re: EL expression for id attributes?
            ziphyre

            On my project, I got a <a4j:include> with a dynamic viewId, I change its value and than rerender it with a command link and it works...

            • 18. Re: EL expression for id attributes?
              grimholtz

               

              "ziphyre" wrote:
              On my project, I got a <a4j:include> with a dynamic viewId, I change its value and than rerender it with a command link and it works...


              Ziphyre, can you please post the code before and after the a4j:include? And, are you using Facelets?

              • 19. Re: EL expression for id attributes?
                bossdev

                Can you please post /share the working code -Thanks

                • 20. Re: EL expression for id attributes?
                  ziphyre

                  Sorry for the late reply,

                  Here is a sample working code.

                  Ps: I use seam but in the same result can be done with faces-config managed beans...
                  grimholtz: yes I'm using facelets 1.1.14


                  test.xhtml:

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:rich="http://richfaces.org/rich"
                   xmlns:a4j="http://richfaces.org/a4j">
                  
                  <body>
                   <h:form>
                   <a4j:commandLink value="Toggle View" action="#{testBean.toggleView}"
                   reRender="testForm" />
                   </h:form>
                  
                   <h:form id="testForm">
                   <a4j:include viewId="#{testBean.viewId}" />
                   </h:form>
                  </body>
                  
                  </html>


                  test1.xhtml

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:rich="http://richfaces.org/rich"
                   xmlns:a4j="http://richfaces.org/a4j">
                  
                   <ui:composition>
                   <p> Test page 1 </p>
                   </ui:composition>
                  
                  </html>


                  test2.xhtml

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:rich="http://richfaces.org/rich"
                   xmlns:a4j="http://richfaces.org/a4j">
                  
                   <ui:composition>
                   <p> Test page 2 </p>
                   </ui:composition>
                  
                  </html>


                  TestBean.java:

                  
                  import org.jboss.seam.ScopeType;
                  import org.jboss.seam.annotations.Name;
                  import org.jboss.seam.annotations.Scope;
                  
                  
                  @Name("testBean")
                  @Scope(ScopeType.SESSION)
                  public class TestBean {
                   private String viewId;
                  
                   public TestBean() {
                   viewId = "/test1.xhtml";
                   }
                  
                   public String getViewId() {
                   return viewId;
                   }
                  
                   public void setViewId(String viewId) {
                   this.viewId = viewId;
                   }
                  
                   public void toggleView() {
                   if ( getViewId().equals("test1.xhtml") ) {
                   setViewId("test2.xhtml");
                   }
                   else {
                   setViewId("test1.xhtml");
                   }
                   }
                  }


                  • 21. Re: EL expression for id attributes?
                    grimholtz

                    I never was able to get a4j:include to use an EL expression for viewId. Instead, I read these articles:

                    http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets [it's helpful to read the comments at the end, too]
                    http://wiki.java.net/bin/view/Projects/FaceletsFAQ#Why_doesn_t_my_c_if_ui_repeat_ui
                    http://andrewfacelets.blogspot.com/2008/03/build-time-vs-render-time.html

                    and used ui:include inside c:forEach (note I'm using facelets).

                    • 22. Re: EL expression for id attributes?
                      ionutbarau

                      Hi guys,

                       

                      Has anyone found a solution for this ?

                       

                      I am using RF 4, and I am trying to set the id of tree node from backing bean, hopeing to set a default selected node.

                       

                      thanks

                      1 2 Previous Next