I think an instance of your TabSupport class is created every time you change the tab (that's what I remember, I had a similiar implementation at the beginning). That would explain why your selectedTabIndex property value does not reflect your current index, but always the default value.
 
You may try to create a separate Backing-Bean class to store the selectedTabIndex. And you can update this property from the processTabChange method in another class (no Backing-Bean) by looking up a reference to the Backing-Bean every time your processTabChange method is called. 
 
-Matthias
 
 
 -----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]Im Auftrag von Hasnain Badami
Gesendet: Mittwoch, 5. April 2006 18:34
An: MyFaces Discussion
Betreff: Problem with PanelTabbedpane

Hi
 
I m trying to use the panel tabbed pane with the serversidetabswitch = true. Therefore I have declared a tab change listener with the following source code
 

public class TabSupport implements Serializable, TabChangeListener
{
 private static final long serialVersionUID = 1L;
 int selectedTabIndex;
 
 public TabSupport()
 {
 }
 public int getSelectedTabIndex() {
  //System.out.println(" Property getSelectedTabIndex() accessed " + selectedTabIndex);
  return selectedTabIndex;
 }
 public void setSelectedTabIndex(int selectedTabIndex) {
  //System.out.println(" Property setSelectedTabIndex() accessed");
  this.selectedTabIndex = selectedTabIndex;
 }

 public void processTabChange(TabChangeEvent event){
  System.out.println("TabSupport:processTabChange() called " + event.getNewTabIndex() + " " + event.getPhaseId());
  this.selectedTabIndex = event.getNewTabIndex();
 }
}

When I change the tab the listener is invoked which sets selectedTabIndex value accordingly and I can see this through the system message. But in the generated html the selected tab content doesnt show meaning selectedTabIndex is still 0. It hasnt been assigned to the new value or has been overwritten. TabSupport is in the session scope. Following is my jsp code

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<%@

page contentType="text/html;charset=UTF-8" language="java" %>

<%@

taglib prefix="c" uri ="http://java.sun.com/jstl/core" %>

<%@

taglib prefix="f" uri ="http://java.sun.com/jsf/core" %>

<%@

taglib prefix="h" uri ="http://java.sun.com/jsf/html" %>

<%@

taglib uri="http://myfaces.apache.org/tomahawk " prefix="t"%>

 

<

f:view>

<f:loadBundle basename="com.prytania.resource.Messages " var="messages"/>

<html>

<head>

<title><h:outputText value="#{messages['title']}"/></ title>

<t:stylesheet path="/report.css" />

</head>

<body>

<h:form id="portfolioFatherForm" >

<f:subview id="header" >

<jsp:include page="inc/page_header.jsp" />

</f:subview>

<f:verbatim>

<br/>

</f:verbatim>

<t:panelTabbedPane

selectedIndex="#{tabSupport.selectedTabIndex}"

styleClass="tabbedPane"

width="100%"

bgcolor="#FFFFCC"

activeTabStyleClass="activeTab"

inactiveTabStyleClass="inactiveTab"

activeSubStyleClass="activeSub"

inactiveSubStyleClass="inactiveSub"

tabContentStyleClass="tabContent"

serverSideTabSwitch="true"

>

<t:panelTab label=" #{messages['portfolio_summary']}" >

<f:subview id="tabportfoliosummary" rendered="#{(tabSupport.selectedTabIndex==0)}" >

<jsp:include page="portfoliosummary.jsp " />

</f:subview>

</t:panelTab>

<t:panelTab label=" #{messages['portfolio_detail']}">

<f:subview id="tabportfoliodetail" rendered="#{(tabSupport.selectedTabIndex==1)}" >

<jsp:include page="portfoliodetail.jsp " />

</f:subview>

</t:panelTab>

<t:panelTab label=" #{messages['portfolio_statistics']}">

<f:subview id="tabportfoliostatistics" rendered="#{(tabSupport.selectedTabIndex==2)}" >

<jsp:include page="portfoliostatistics.jsp " />

</f:subview>

</t:panelTab>

<t:tabChangeListener type="com.prytania.listeners.TabSupport " />

</t:panelTabbedPane>

<f:subview id="footer" >

<jsp:include page="inc/page_footer.jsp" />

</f:subview>

</h:form>

</body>

<html>

</

f:view>

 

I shall be highly obliged with any responses.

Hassnain

Reply via email to