3 Replies Latest reply on Sep 24, 2008 3:03 PM by 487442

    BUG: af:pannelTabbed and af:showDetailItem setting active tab


      I have the following page
      <?xml version='1.0' encoding='UTF-8'?>
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
          <af:document title="Test page">
              <af:commandButton text="Set 'A' tab as active" partialSubmit="true"
                <af:setActionListener from="A" to="#{pageFlowScope.activeTab}"/>
                <af:panelTabbed partialTriggers="cb1">
                  <af:showDetailItem text="A"
                    <af:setPropertyListener from="A" to="#{pageFlowScope.activeTab}"
                  <af:showDetailItem text="B"
                    <af:setPropertyListener from="B" to="#{pageFlowScope.activeTab}"
      When I load the page I switch to the 'B' tab and press the button, and now the 'A' tab is active. This works as expected. But if, after loading the page, I click on tab B, then A, then B again and then click the button, tab B stays active (the value in pageFlowScope is changed to A but the tab seems to ignore that). Can anyone help me with this?
        • 1. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
          Hi Pedja,

          The panel tabbed is a strange component as it overwrite the value of the disclosed attribute when you switch tabs. Furthermore, it overwrite it using a constant value. So, given you have two tabs A and B, those will be represented in the JSF tree with the following (I'm using pseudo code with some not existing methods, but you should get the idea):
          RichShowDetailItem tabA;
          RichShowDetailItem tabB;
          // Initial state is
          tabA.getValueExpression("disclosed") == "#{pageFlowScope.activeTab=='A'}"
          tabA.getLocalAttribute("disclosed") == null;
          tabA.getDisclosed() == "#{pageFlowScope.activeTab=='A'}".getValue(); // Since local value is null
          tabB.getValueExpression("disclosed") == "#{pageFlowScope.activeTab=='B'}"
          tabB.getLocalAttribute("disclosed") == null;
          tabB.getDisclosed() == "#{pageFlowScope.activeTab=='B'}".getValue(); // Since local value is null
          // After first render, assuming "#{empty pageFlowScope.activeTab}" since the panelTabbed's renderer ALTER the component instance
          tabA.getValueExpression("disclosed") == "#{pageFlowScope.activeTab=='A'}"
          tabA.getLocalAttribute("disclosed") == true;
          tabA.getDisclosed() == true; // Since local value is not null, it gets priority over the ValueExpression
          tabB.getValueExpression("disclosed") == "#{pageFlowScope.activeTab=='B'}"
          tabB.getLocalAttribute("disclosed") == false;
          tabB.getDisclosed() == false;  // Since local value is not null, it gets priority over the ValueExpression
          // After that point the local value is ALWAYS used, ignoring your value expression
          Therefore, the only solution is to JSF bind your detail item in a bean and use a disclosureListener on the panelTabbed. You then switch the pageFlowScope attribute value in the listener as well as call the setDisclosed method on the bound tab with the right value, you can then add the partial target manually while at it since it's going to simplify your page a little.


          ~ Simon
          1 person found this helpful
          • 2. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
            Hi Simon,

            Thanks for your help, I started coding this in backing bean and then I stumbled on showDetailItem's attribute disclosedTransient that does exactly what is needed. After setting it to true on tab B everything works. Thanks again!

            • 3. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
              Hi Pedja,

              Ohhhhhh, never saw this one, must be new to Rich Client, I'm going to use it as well then as I had exactly the same use case not so long ago :)

              ~ Simon