2 Replies Latest reply on Nov 24, 2009 9:59 AM by Olli H.

    panelBar / panelBarItem - How expand/collapse on client usin

    Koiti Issayama Newbie


      I need change dinamically a menu make with richfaces panelBar/panelBarItem.

      Can I change active panelBarItem using javascript ?
      How i do this ?

        • 1. Re: panelBar / panelBarItem - How expand/collapse on client
          David Greenberg Newbie

          I just had this same issue. Unfortunately, there's no good way to do this. There is, however, a hack:

           <rich:panelBarItem id="panel1" />
           <rich:panelBarItem id="panel2" />
           <rich:panelBarItem id="panel3" />
           // <![CDATA[
           function switchToPanel(panel) {
           if (document.createEventObject) {
           var event = document.createEventObject();
           panel.firstChild.fireEvent('onclick', event);
           } else {
           var event = document.createEvent('MouseEvents');
           event.initEvent('click', true, true);
           // ]]>
           <a4j:commandButton value="test1"
           oncomplete="switchToPanel(#{rich:element('panel1'});" />
           <a4j:commandButton value="test2"
           oncomplete="switchToPanel(#{rich:element('panel2'});" />
           <a4j:commandButton value="test3"
           oncomplete="switchToPanel(#{rich:element('panel3'});" />

          It would be really nice if the initialize function in the PanelBar prototype defined $(panelId).component to be equal to the PanelBar instance, similar to how the ProgressBar component works. Until then, the code above is a decent workaround.


          • 2. Re: panelBar / panelBarItem - How expand/collapse on client
            Olli H. Newbie

            i tried out your workaround but i get following error

            switchToPanel(#{rich:element('panel1'});" contains invalid expression(s): javax.el.ELException: Error Parsing: switchToPanel(#{rich:element('panel1'});

            Do i need something else?