Invoke JavaScript when specific tab is clicked

jsf, primefaces

Solution

There are two ways to hook up on tab change events:

Use `onTabChange` attribute of `<p:tabView>` tag to execute a callback function on the appropriate event:

<p:tabView onTabChange="handleTabChange(index)">
//tabs
</p:tabView>

Use `oncomplete` attribute of `<p:ajax>` tag to execute a JS function when AJAX call completes successfully:

        <p:ajax event="tabChange" listener="#{tabBean.onTabChange}" oncomplete="handleOncomplete(xhr, status, args)"/>

Problem

i am exploring the tab components in primefaces http://www.primefaces.org/showcase/ui/tabviewChangeListener.jsf , and i was wondering if it's possible to invoke a JavaScript when a specific tab is being clicked. please advise, thanks.

Original source