1

JSP code

<t:panelTabbedPane align="left"  serverSideTabSwitch="false" styleClass="tabbedPane" 
            activeTabStyleClass="activeTab" inactiveTabStyleClass="inactiveTab" width="100%" cellpadding="0"
            cellspacing="0" tabContentStyleClass="tabContent" style="margin-top:0px;text-align:center"
            selectedIndex="#{myBB.selectedTab}">

/*******************************************/

Backing Bean Code:

private int selectedIndex;



    public int getSelectedIndex() {
        System.out.println("getter of selectedIndexis called "+selectedIndex);
        return selectedIndex;
    }

    public void setSelectedIndex(int selectedIndex) {
        System.out.println("Setter of selectedIndexis called "+selectedIndex);
        this.selectedIndex= selectedIndex;
    }

The backing bean is of session scope. When i change panelTab in the screen and click on submit button, always the default panel is being shown. I checked the console to find the sysout from setter of selectedIndex.But in console it is not being printed which means(I suppose) the selectedIndex is not being posted to the server.I'm using JSF version 1.1. Can any one suggest how to make this work ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Chaitanya Gudala
  • 305
  • 1
  • 3
  • 22
  • System.out.println("Request map "+FacesContext.getCurrentInstance().getExternalContext().getRequestMap()); System.out.println("Request Param map "+FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()); I tried this to find whether selectedIndex is getting posted to the server.Even in this also there is no such param. – Chaitanya Gudala Sep 23 '12 at 14:07
  • 1
    is your `t:panelTabbedPane ` inside a `h:form`? place the submit button method inside that bean and try to `System.out.println(selectedIndex);` – Daniel Sep 23 '12 at 14:25
  • http://stackoverflow.com/questions/8537369/jsf-otabbedpane-issue-changing-selectedindex – Alvin Pradeep Sep 23 '12 at 16:25
  • @Daniel Yes, both the t:panelTabbedPane and the submit button are in the same form.Also there is a single form in the whole page – Chaitanya Gudala Sep 24 '12 at 06:28
  • what about the `System.out.println(selectedIndex);` what is being printed ? – Daniel Sep 24 '12 at 06:30
  • @Daniel selectedIndex is coming as 0,the default value. – Chaitanya Gudala Sep 24 '12 at 09:44
  • do you have nested forms on your page ? a form that wraps the `t:panelTabbedPane` and form/s inside the `t:panelTabbedPane` ? – Daniel Sep 24 '12 at 10:00
  • @Daniel No, I dont have any nested form/s inside my complete page. – Chaitanya Gudala Sep 24 '12 at 11:16

2 Answers2

1

According to the docs, selectedIndex is the default tab index to use, not the actual currently selected tab index.

Having said that, you can use a <t:tabChangeListener> to pick up the currently selected tab.

BoneGoat
  • 554
  • 5
  • 9
1

For anyone that may come across this:

You need to set serverSideTabSwitch="true" and use a tabChangeListener, or else the tab switches (and the known tab index) is entirely done in the client.

drunkel
  • 228
  • 1
  • 11