activeIndex in nested Tabs

UI Components for JSF
Post Reply
ulric2
Posts: 11
Joined: 03 Jan 2011, 23:30

05 Jan 2011, 19:57

I found strange behaviours using activeIndex in nested tabs.
I join a sample testCase to show the problem.

When all first tabs (on the left) are selected, the activeIndex sent to the bean are correct (all to 0).
When I choose an other index on level 2, level 1 takes the same value (1)

When I choose an other index on level 3, level 1 and 2 takes the same value (1)
It seems that upper levels take the same values than their "child".

There is no use of ajax, just a simple form post.

I didn't found any bug in forum for this case (only for dynamic tabs)

Did I misunderstood something ?

Thx for your answers

ulric



Here the sample test.xhtml

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:upt="http://java.sun.com/jsf/composite/upt"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
>

<ui:composition template="/WEB-INF/templates/base.xhtml">
        <ui:define name="content">
                <p:panel header="Test">
                        <h:form>
                                <p:tabView activeIndex="#{testBean.selectedTabx}">
                                        <p:tab title="Level1">
                                                <p:tabView activeIndex="#{testBean.selectedTab1x}">
                                                        <p:tab title="Level11">
                                                                <p:tabView activeIndex="#{testBean.selectedTab11x}">
                                                                        <p:tab title="Level111">
                                                                        </p:tab>
                                                                        <p:tab title="Level112">
                                                                        </p:tab>
                                                                </p:tabView>
                                                        </p:tab>
                                                        <p:tab title="Level12">
                                                                <p:tabView activeIndex="#{testBean.selectedTab12x}">
                                                                        <p:tab title="Level121">
                                                                        </p:tab>
                                                                        <p:tab title="Level122">
                                                                        </p:tab>
                                                                </p:tabView>
                                                        </p:tab>
                                                </p:tabView>
                                        </p:tab>
                                        <p:tab title="Level2">
                                                <p:tabView activeIndex="#{testBean.selectedTab2x}">
                                                        <p:tab title="Level21">
                                                                <p:tabView activeIndex="#{testBean.selectedTab21x}">
                                                                        <p:tab title="Level211">
                                                                        </p:tab>
                                                                        <p:tab title="Level212">
                                                                        </p:tab>
                                                                </p:tabView>
                                                        </p:tab>
                                                        <p:tab title="Level22">
                                                                <p:tabView activeIndex="#{testBean.selectedTab22x}">
                                                                        <p:tab title="Level221">
                                                                        </p:tab>
                                                                        <p:tab title="Level222">
                                                                        </p:tab>
                                                                </p:tabView>
                                                        </p:tab>
                                                </p:tabView>
                                        </p:tab>
                                </p:tabView>
                                <h:commandButton
                                        action="#{testBean.none}"
                                        title="Refresh"
                                />
                        </h:form>
                </p:panel>
        </ui:define>
</ui:composition>
</html>
and the test bean

Code: Select all

package com.upt.protectionGenerateur.beans;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class TestBean
{
    private int    selectedTabx;
    private int    selectedTab1x;
    private int    selectedTab11x;
    private int    selectedTab12x;
    private int    selectedTab2x;
    private int    selectedTab21x;

    private int    selectedTab22x;

    private void displaySelectedTabs()
    {
        System.out.println("Tabs positions :");
        System.out.println(selectedTabx);
        System.out.println("\t" + selectedTab1x);
        System.out.println("\t\t" + selectedTab11x);
        System.out.println("\t\t" + selectedTab12x);
        System.out.println("\t" + selectedTab2x);
        System.out.println("\t\t" + selectedTab21x);
        System.out.println("\t\t" + selectedTab22x);

    }

    public int getSelectedTab11x()
    {
        return selectedTab11x;
    }

    public int getSelectedTab12x()
    {
        return selectedTab12x;
    }

    public int getSelectedTab1x()
    {
        return selectedTab1x;
    }

    public int getSelectedTab21x()
    {
        return selectedTab21x;
    }

    public int getSelectedTab22x()
    {
        return selectedTab22x;
    }

    public int getSelectedTab2x()
    {
        return selectedTab2x;
    }

    public int getSelectedTabx()
    {
        return selectedTabx;
    }

    public void none()
    {
        displaySelectedTabs();
    }

    public void setSelectedTab11x(final int param_selectedTab11x)
    {
        selectedTab11x = param_selectedTab11x;
    }

    public void setSelectedTab12x(final int param_selectedTab12x)
    {
        selectedTab12x = param_selectedTab12x;
    }

    public void setSelectedTab1x(final int param_selectedTab1x)
    {
        selectedTab1x = param_selectedTab1x;
    }

    public void setSelectedTab21x(final int param_selectedTab21x)
    {
        selectedTab21x = param_selectedTab21x;
    }

    public void setSelectedTab22x(final int param_selectedTab22x)
    {
        selectedTab22x = param_selectedTab22x;
    }

    public void setSelectedTab2x(final int param_selectedTab2x)
    {
        selectedTab2x = param_selectedTab2x;
    }

    public void setSelectedTabx(final int param_selectedTabx)
    {
        selectedTabx = param_selectedTabx;
    }

}
PrimeFaces 3.0.M4, Glassfish v3.1.1, Mojarra 2.1.3 (FCS b02), Eclipse Indigo

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 77 guests