2 Replies Latest reply on Apr 17, 2007 5:25 PM by sergeysmirnov

    tabPanel backing bean

    twocoasttb

      Are there any examples available that demonstrate using a tabPanel with a backing bean or a seam component? I'm having trouble getting a tabPanel to work with a backing component in a seam application. If I have a simple tab panel view like this:

      <h:form id="test">
      <rich:tabPanel id="tabs" switchType="server" binding="#{tabManager.profileTabPanel}" value="#{tabManager.currentTab}">
       <rich:tab id="first" label="First">
       First
       </rich:tab>
       <rich:tab id="second" label="Second">
       Second
       </rich:tab>
      </rich:tabPanel>
      </h:form>

      And a seam component like this:

      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("tabManager")
      public class TabManagerBean implements TabManager {
       private HtmlTabPanel profileTabPanel;
       private String currentTab;
      
       public HtmlTabPanel getProfileTabPanel() {
       return profileTabPanel;
       }
      
       public void setProfileTabPanel(HtmlTabPanel profileTabPanel) {
       this.profileTabPanel = profileTabPanel;
       }
      
       public String getCurrentTab() {
       return currentTab;
       }
      
       public void setCurrentTab(String tabName) {
       this.currentTab = tabName;
       }
      
       @Remove @Destroy
       public void destroy() {}
      
      }

      I get an IllegalArgumentException (argument type mismatch) on the profileTabPanel property when the page is rendered. I'm sure I'm doing something stupid here, but haven't yet figured out what.

        • 1. Re: tabPanel backing bean
          nbelaevski

          Hello!

          Try to define profileTabPanel as UIComponent, getters & setters too and cast to UITabPanel internally in setter.

          • 2. Re: tabPanel backing bean

            The issue appeared because Seam Bean and HtmlTabPanel are loaded by different classloaders. The bean's class HtmlTabPanel does not match HtmlTabPanel class loaded in application. The workaround above should work. However, you can meet other similar problems in future having such environment configuration. Consult with the Seam documentation how to avoid unexpected ClassCast exceptions.