1 Reply Latest reply on Sep 14, 2011 3:40 AM by chaosguru

    Dynamic incude page in xhtml page using facelets

    chaosguru

      I have a favourites chart, on click on an item in the chart, I have to inlcude a page in rich:tab. The favourites chart is built using jQuery and on each leaf click event I do a ui:include with jstl check. Please find the below code.

       

      <rich:tabPanel>
             
      <rich:tab label="#{mnOrdrMsgs.mainordr}" immediate="true"
                 
      id="mainorderTab" styleClass="tabPanel">

                 
      <c:if test="${favouritesBean.selectedNaviItem != null}">
                     
      <ui:include src="#{favouritesBean.selectedPage}" />
                 
      </c:if>

                 
      </rich:tab>
             
      <rich:tab label="#{mnOrdrMsgs.archiv}" immediate="true"
                 
      id="archivTab" styleClass="tabPanel">
              Archive
         
      </rich:tab>
         
      </rich:tabPanel>

       

       

      The problem is the value of favouritesBean.selectedPage is always null. Can anyone please help in this case. I am really stuck since 2 days.

       

      first I set the value in the backing bean from javascript(code below).

      <a4j:form>

      <a4j:jsFunction name="updateTab" reRender="mainorderTab">

      <a4j:actionparam name="naviItemSelected" assignTo="# {favouritesBean.selectedNaviItem}" />

      </a4j:jsFunction>

      </a4j:form>

       

      later in the bean the value is checked(code below)

       

      public String getSelectedPage(){

      if(this.selectedNaviItem.equals("Auftragstemplateladen")){

      selectedPage="/protected/mainorder/auftragtemplate.xhtml"; }

      return this.selectedPage; }

       

      Is this the right way?

        • 1. Re: Dynamic incude page in xhtml page using facelets
          chaosguru

          I think the problem come from the assignement of favouritesBean.selectedNaviItem." 

          The bean attribute selectedNaviItem is null for the first time render phase hence the selectedNaviItem is not evaluated and by default always the selectedPage value is being displayed.

          Solution:

          Initialise the bean with empty string or default value.