Primefaces tabview activeIndex not updated on server

204 Views Asked by At

Porting my web-application to a newer version I faced an odd disfunction in behaviour of activeIndex from p:tabView UI component. Shortly said: In my existing web-application it all works fine, in my newer version activeIndex is not beeing updated on the backing bean. Both web-applications use the same code! And also the same java-libraries and Primefaces version (8.0).

xhtml code is:

<p:tabView id="TVMR"
    styleClass="menuRight zw-fontFamily zw-green zw-fontNormal"
    dynamic="true" cache="false" orientation="left" 
    widgetVar="tabViewMenuRight"
    style="border: 0px solid black; padding: 0px !important;"
    activeIndex="#{accViewer.tabIndex}">

    <p:tab title="" disabled="true" id="tab0">
    </p:tab>

    <p:tab title="Accommodatie" id="tab1">
    </p:tab>

    <p:tab title="Location" id="tab2">
    </p:tab>

    ......

    <p:ajax event="tabChange" listener="#{accViewer.onChange}"
        update="@this, accomMenuPanel, TVMR, cac010, cac020, cac030, cac040"
        resetValues="true" />
</p:tabView>

java code is:

public void setTabIndex(int tabIndex) {
    System.out.println(thisClassName + ": setTabIndex (1) - " + tabIndex);
    this.tabIndex = tabIndex;
}

public void onChange(TabChangeEvent<TabChangeEvent> event) {

    System.out.println(thisClassName + ": onChange (1) - " + event.getTab().getId());

    if (AppUtils.isInteger(event.getTab().getId().substring(3))) {
        int i = Integer.parseInt(event.getTab().getId().substring(3));
        if (this.tabIndex != i) {
            System.out.println(thisClassName + ": onChange (2) - " + i);
            setTabIndex(i);
        }
    }
} 

On my newer website I had to build a workaround to get everything good functioning again. So in case of when the automatic tabIndex is not beeing updated by p:tabView, It will be updated by onChange(TabChangeEvent event). Here you see the results of both web-applications compared:

Existing web-app shows:

viewer.AccViewer: setTabIndex (1) - 4
viewer.AccViewer: onChange (1) - tab4

New web-app shows:

viewer.AccViewer: setTabIndex (1) - 1
viewer.AccViewer: onChange (1) - tab4
viewer.AccViewer: onChange (2) - 4
viewer.AccViewer: setTabIndex (1) - 4

My configuration is:

Eclipse 18-12;
JDK v11.0;
Apache Tomcat (TomEE)/9.0.41 (8.0.6);
JSF2.3;
myfaces2.3;
Primefaces 8.0;

If anyone could give a hint or explanation of what may cause this unexpected behaviour, I would very much apreciate it! Solving this type of disfunctioning is much time consuming and unless I made some mistake myself, I feel that Primefaces framework (which I find is a great engineered java UI-layer!) should be a bit more stable. Maybe Primefaces could investigate some time to get p:tabview tabIndex server update process reliable!?

0

There are 0 best solutions below