3 Replies Latest reply on Mar 17, 2009 8:35 PM by Nick Belaevski

    tabPanel: session scoped bean generates too many valueChange

    Rob Stevens Newbie

      If my valueChange listener for a tabPanel is a session scoped bean, each time I revisit the page that contains the tabPanel a new valueChangeListener is added.

      This causes the processValueChange method to be call for each valueChangeListener. I would expect that the processValueChange listener in my backing bean to be called only once.

      My application requires that his bean be session scoped so changing the scope is not a viable option.

      Thanks in advance!

      The following code illustrates this:

      import javax.faces.event.AbortProcessingException;
      import javax.faces.event.ValueChangeEvent;
      import javax.faces.event.ValueChangeListener;
      import org.richfaces.component.html.HtmlTabPanel;
      public class PanelTestBean implements ValueChangeListener {
       private HtmlTabPanel tabs = new HtmlTabPanel();
       public HtmlTabPanel getTabs() {
       return tabs;
       public void setTabs(HtmlTabPanel tabs) {
       this.tabs = tabs;
       System.out.println("Number of listeners: " + tabs.getValueChangeListeners().length);
       public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
       System.out.println("\nFire event:\nOld tab:" + event.getOldValue());
       System.out.println("New tab:" + event.getNewValue());
       public String getListenerCount() {
       return "Number of listeners: " + getTabs().getValueChangeListeners().length;
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <html xmlns="http://www.w3.org/1999/xhtml"
      <ui:composition template="layout/layout.xhtml">
       <ui:define name="title">Panel Test</ui:define>
       <ui:define name="content">
       <rich:tabPanel switchType="ajax" binding="#{panelTestBean.tabs}"
       <rich:tab label="Panel 1" id="P1">
       <h:outputText value="#{panelTestBean.listenerCount}" />
       <rich:tab id="P2" label="Panel 2">
       <h:outputText value="#{panelTestBean.listenerCount}" />
       <rich:tab id="P3" label="Panel 3">
       <h:outputText value="#{panelTestBean.listenerCount}" />