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

    Ajax not working when using include with dynamic value

    usmanibrahim

      Hello

       

      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"/>

                              </f:facet>

                              <h:panelGrid columns="1">

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

                              </h:panelGrid>

                          </rich:panel>

       

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

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

                          </rich:panel>

                          </h:panelGrid>

       

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

       

      <ui:composition 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:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich">         

                        <a4j:form>

                                <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" />

                                    </h:inputText>

       

                                    <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}" />                                   

                                    </h:panelGroup>

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

                        </a4j:form>        

      </ui:composition>

       

      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.