3 Replies Latest reply on Apr 29, 2009 2:03 PM by nbelaevski

    How to know which panelBarItem I'm on?

      This is my xhtml

      <rich:panelBar height="400" width="500" binding="#{index.panelBar}">
       <a4j:support event="onitemchange" action="#{index.changePanelBarItem}" ajaxSingle="true"/>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
      </rich:panelBar>


      On the server side:
      public void changePanelBarItem() {
       System.out.println(panelBar.getSelectedPanel());
      }

      I realize that on the server I get the name of the panel bar item that the user leaves from, not the one he is going to.

      In order to get the panel bar item the user is going to, I use:
      <rich:panelBar height="400" width="500" binding="#{index.panelBar}">
       <a4j:support event="onitemchange" action="#{index.doNothing}" ajaxSingle="true" oncomplete="changePanelBarItem();"/>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
       <rich:panelBarItem label="..." name="...">...</rich:panelBarItem>
      </rich:panelBar>
      <a4j:jsFunction action="#{index.changePanelBarItem}" name="changePanelBarItem"/>


      Is there any better way than that?

        • 1. Re: How to know which panelBarItem I'm on?
          nbelaevski

          Hello,

          You can try this:

          <rich:panelBar>
           <rich:panelBarItem>
           <a4j:support event="onenter" action="..." />
          
           </rich:panelBarItem>
           <rich:panelBarItem>
           <a4j:support event="onenter" action="..." />
          
           </rich:panelBarItem>
           ...
           </rich:panelBar>


          • 2. Re: How to know which panelBarItem I'm on?
            frer

            I know this is an old thread but I have tried the a4j: support on the panelBarItem and my action is never called. I have used exactly the same code as below but the call is not made.

            <rich:panelBar>
            <rich:panelBarItem>
            <a4j:support event="onenter" action="#{bean.switchToBasicMode}" />

            </rich:panelBarItem>
            <rich:panelBarItem>
            <a4j:support event="onenter" action="#{bean.switchToAdvancedMode}" />

            </rich:panelBarItem>
            ...
            </rich:panelBar>
            I use RichFaces 3.3.0.

            Any clue?

            • 3. Re: How to know which panelBarItem I'm on?
              nbelaevski

              Please post full page code.