package com.prytania.model.backingbeans;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import org.apache.log4j.Logger;
import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
import org.apache.myfaces.custom.tabbedpane.TabChangeEvent;
import org.apache.myfaces.custom.tabbedpane.TabChangeListener
;
public class PortfolioDetailTabManager implements TabChangeListener
{
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(PortfolioDetailTabManager.class);
public PortfolioDetailTabManager()
{
log.info("Executing PortfolioDetailTabManager()");
log.info("Exiting PortfolioDetailTabManager()");
}
public void processTabChange(TabChangeEvent event) throws AbortProcessingException
{
log.info("TabSupport:processPortfolioDetailTabChange() called " + event.getNewTabIndex());
PortfolioTabIndex tabIndices = (PortfolioTabIndex)FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(
FacesContext.getCurrentInstance(), "portfolioTabIndex");
HtmlPanelTabbedPane tabbedPane = (HtmlPanelTabbedPane)event.getComponent();
if(tabIndices!=null)
tabIndices.setIndex(event.getNewTabIndex());
if(tabbedPane!=null)
tabbedPane.setSelectedIndex(event.getNewTabIndex());
}
}
PortfolioTabIndex
package com.prytania.model.backingbeans;
import java.io.Serializable;
import org.apache.log4j.Logger;
/**
*
*
author hbadami
*
jsf.bean
* name="portfolioTabIndex"
* scope="request"
*/
public class PortfolioTabIndex implements Serializable
{
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(PortfolioTabIndex.class);
private int index=0;
public int getIndex() {
return index;
}
public void setIndex(int index)
{
log.info("The old index is " + this.index + " the new index is " + index);
this.index = index;
}
public PortfolioTabIndex()
{
log.info("Executing PortfolioTabIndex()");
log.info("Exiting PortfolioTabIndex()");
}
}
now when I execute this code, only the code in the selected tab gets executed, but the tabbed pane creates additonal tabs automatically when you move between tabs back and forth. Any idea why is this happening? Thanks in advance