PrimeFaces TabView

It is a container component which is used to group content in tabs at the same web page. The <p:tabView> component is used to create container. The <p:tab> is a sub component of <p:tabView> which is used to create tab individually. It is useful when we want to show more information at the same web page.

TabView Attributes

AttributeDefault valueTypeDescription
renderedtrueBooleanIt takes boolean value to specify the rendering of the component.
activeIndex0IntegerIt is used to set index of the active tab.
effectnullStringIt is used to set name of the transition effect.
effectDurationnullStringIt is used to set duration of the transition effect.
dynamicfalseBooleanIt enables lazy loading of inactive tabs.
cachetrueBooleanIt is used to set cache.
onTabChangenullStringIt executes when a tab is clicked.
onTabShownullStringIt executes when a tab is shown.
onTabClosenullStringIt executes on tab close.
stylenullStringIt is used to set inline style of the main container.
varnullStringIt is a name of iterator to refer an item in collection.
valuenullObjectIt is a collection model to display dynamic tabs.
orientationtopStringIt is used to set orientation of tab headers.
dirltrStringIt defines text direction, valid values are ltr and rtl.
scrollablefalseBooleanWhen enabled, tab headers can be scrolled horizontally instead of wrapping.
prependIdtrueBooleanIt is used to prepend id.
tabindex0StringIt specify position of the element in the tabbing order.

Example

Here, in the following example, we are implementing <p:tabView> component. This example contains the following files.

JSF File

// tabView.xhtml

Output:

PrimeFaces TabView 1
PrimeFaces TabView 2