1 Reply Latest reply on Jun 9, 2011 3:51 PM by Juan Gomez

    Ajax not working when using include with dynamic value

    Usman Ibrahim Newbie



      I am planning to build a page with tree as menu in the left side of the page using the following code.


      <h:panelGrid columns="2">

                        <rich:panel id="menu" style="width:250px; height:500px">

                             <f:facet name="header">

                                  <h:outputText value="Selections"/>


                              <h:panelGrid columns="1">

                                  <rich:tree value="#{treeBean.top}" nodeSelectListener="#{treeBean.selectionListener}" reRender="content" ajaxSubmitSelection="true"/>




                          <rich:panel id="content1" header="User : #{treeBean.selectedText}" style="width: 550px; height:500px">

                                 <a4j:include viewId="#{treeBean.selectedPage}" />




      By default first.xhtml is the page assigned to treeBean.SelectedPage


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"







                                <a4j:keepAlive beanName="user" />

                              <!-- <a4j:outputPanel id="ri81" header="RichFaces Greeter" style="width: 100%"> -->

                                    <h:outputText id="ri61" value="Your name: " />

                                    <h:inputText id="ri51" value="#{user.name}" >

                                          <f:validateLength minimum="1" maximum="30" />



                                    <a4j:commandButton id="ri11" value="Get greeting" reRender="greeting" />


                                    <h:panelGroup id="greeting" >                             

                                            <h:outputText id="ri28" value="#{treeBean.selectedPage}" />

                                          <h:outputText id="ri21" value="Hello, " rendered="#{not empty user.name}" />

                                          <h:outputText id="ri31" value="#{user.name}" />

                                          <h:outputText id="ri41" value="!" rendered="#{not empty user.name}" />                                   


                              <!-- </a4j:outputPanel> -->




      The problem is, if I use viewId="#{treeBean.selectedPage}", the page is not refreshed if I click commandbutton. But if I hardcode the value instead of a value from bean i.e. viewId="/first.xhtml", its working fine.


      Much appreciated for your valueable time and feedback.