Search code examples
jspjsfrichfacesjsf-2

rerender rich:tab contnet


I have try to provide the web2.0 support for my application.For that i wants to provide the rich:tabpanel that can contains number of tabs dynamically.User can add and remove the tabs.For that i use c:foreach for represent the list of rich:tab.The tab contains list of rich:panel contains the details.The panel contains only brief content.By clicking the read more link,the user can read full content.For that i need to rerender the a4j:outputpanel which contains the list of rich:panel.But i can't do this.Because i have used c:freach for render the list of tabs.So i can't get the exact id of the a4j:outputpanel which contains list rich:panels.The a4j:outputpanel doesnot allowed the el expressions.My code snippet is below,

<c:forEach items="#{Home.tabList}" var="homeBean" varStatus="status">
<el:define value="${status.count}" var="rowIndex"/>
 <rich:tab id="homeTab" label="#{homeBean.header}"
                        name="#{homeBean.header}" switchType="client"
                        onlabelclick="coinSliderFunction('coin-slider#{rowIndex}')">
<a4j:outputPanel id="subHeaderPanel">
<h:panelGrid columns="3" cellpadding="3" cellspacing="3"
 id="detailGrid"                                                                   rendered="#{!Home.subHeaderDetailedContentPanelRendered}"
                                                                   columnClasses="layoutContentColumnClass,
                                                                     layoutContentColumnClass,layoutContentColumnClass">

 <%--SubHeader List--%>
 <c:forEach items="#{homeBean.subHeaderBeanList}" var="subHeaderBean" varStatus="subHeaderStatus">
  <rich:panel header="#{subHeaderBean.header}" id="subHeaderPanels">
 <h:outputText id="outputText" value="#{subHeaderBean.briefContent}" escape="false"/>
  <a4j:commandLink value="Read More" id="readMoreLink" 
action="#{Home.navigationHandler}" reRender="subHeaderPanel">    
 <a4j:actionparam name="headerActionParam" value="#{homeBean.header}" assignTo="#{Home.headerName}"/>
<a4j:actionparam name="subHeaderActionParam" value="#{subHeaderBean.header}" assignTo="#{Home.subHeaderName}"/>

</a4j:commandLink>
</rich:panel>
 </c:forEach>
 </h:panelGrid>
  <%--SubHeader Detail Panel--%>
  <h:panelGrid rendered="#{Home.subHeaderDetailedContentPanelRendered}" id="subHeaderGrid">
  <h:outputText id="detailedContent" value="#{Home.subHeaderDetailedContent}" escape="false"/>
 <f:verbatim><center></f:verbatim>                    
 <a4j:commandLink id="backLinks" value="#{platform.backButtonLabel}"
  action="#{Home.backButtonAction}"
                                                                                reRender="leftOutputPanel"/>
 <f:verbatim></center></f:verbatim>
                                               </h:panelGrid>                                                            
                                                        </a4j:outputPanel>                                                       
</rich:tab>
</c:forEach>   

How can i achieve that?Please help me.


Solution

  • Since you can not determine the id of the tabe panels rendered in the forEach loop you have to rerender the panelGrid detailGrid. Take care to cache all values shown on the tabs in your managed beans. If you do so no database call is required and rerendering of all tabs is fast.