3 Replies Latest reply: Sep 24, 2008 10:03 AM by 487442 RSS

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

    Pedja
      Hi,

      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"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <f:view>
          <af:document title="Test page">
            <af:messages/>
            <af:form>
              <af:commandButton text="Set 'A' tab as active" partialSubmit="true"
                                id="cb1">
                <af:setActionListener from="A" to="#{pageFlowScope.activeTab}"/>
              </af:commandButton>
                <af:panelTabbed partialTriggers="cb1">
                  <af:showDetailItem text="A"
                                     disclosed="#{pageFlowScope.activeTab=='A'}">
                    <af:setPropertyListener from="A" to="#{pageFlowScope.activeTab}"
                                            type="disclosure"/>
                  </af:showDetailItem>
                  <af:showDetailItem text="B"
                                     disclosed="#{pageFlowScope.activeTab=='B'}">
                    <af:setPropertyListener from="B" to="#{pageFlowScope.activeTab}"
                                            type="disclosure"/>
                  </af:showDetailItem>
                </af:panelTabbed>
            </af:form>
          </af:document>
        </f:view>
      </jsp:root>
      {code}
      
      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?
      
      Thanks, 
      Pedja                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
        • 1. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
          487442
          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.


          Regards,

          ~ Simon
          • 2. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
            Pedja
            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!

            Pedja
            • 3. Re: BUG: af:pannelTabbed and af:showDetailItem setting active tab
              487442
              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