Archive for the ‘Primefaces’ Category

Today I am going to explain how to set one particular tab as the active tab on some event.

Take a look at the below code snippet which will render a tabview with 3 tabs – Summary, More Details & History upon click on any dashboard item listed in a ui:repeat

<p:tabView dynamic=”true” cache=”false” activeIndex=”#{suhasBean.tabIndex}”>
<p:tab title=”Summary”>
…Summary Of the selected Dashboard Item../
</p:tab>
<p:tab title=”More Details”>
…More Details Of the selected Dashboard Item../
</p:tab>
<p:tab title=”History”>
…History Of the selected Dashboard Item../
</p:tab>
</p:tabView>

Inorder to set an active index on click on dashboard Item, we will define a ‘tabIndex’┬ávariable in SuhasBean and set the desired value in the loadDetails() method in SuhasBean.

 

 

Advertisements