I want to create <f:viewParam>
which sets active tab of <p:tabView>
.
In my page I define a <f:viewParam>
:
<f:viewParam name="tab" value="#{tabView.activeIndex}" />
and <p:tabView>
with binding
:
<p:tabView binding="#{tabView}">
<p:tab title="tab1" />
<p:tab title="tab2" />
<p:tab title="tab3" />
</p:tabView>
But it's not working. If I open my page with parameter ?tab=1
I see this exception:
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'tabView' resolved to null
Why is this happening?
P.S.: in addition to @BalusC answer, you can use binding component property on the viewMap like this:
<f:viewParam name="tab" value="#{viewScope['activeTabIndex']}" />
<p:tabView activeIndex="#{viewScope['activeTabIndex']}">
<p:ajax event="tabChange" />
<p:tab title="tab1" />
<p:tab title="tab2" />
<p:tab title="tab3" />
</p:tabView>
in this case you must provoke ajax-request to put value in the viewMap through <p:ajax event="tabChange" />
or dynamic="true" cache="false"