8 Replies Latest reply on Mar 9, 2010 5:24 AM by scottaii

    rich:simpleTogglePanel - Open/close via a4j:commandLink

    scottaii

      Hello again,

       

      Thank you for all the help i have received before. But i have a new problem!

       

      I have a a4j:commandLink, that, when pressed, will open the simpleTogglePanel and then select a specific rich:tab within the panel.

      I am struggling to find an answer to this and a bit confused on how to tackle it.

      Could a rich:componentControl be usful for this?

       

      Thank you very much,
      Scott

       

      P.S The right click menu on this forum board is annoying because you cant right click to select the correct spelling for a word (in FireFox).

        • 1. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
          scottaii
          Bump, i posted this late
          • 2. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
            ilya_shaikovsky

            1) clientSide solution

             

            There are no client side api documented for this components but you could check components script and call the methods on components which will handle switching.

             

            E.g. for tabPanel it would be

             

            RichFaces.switchTab = function(pane,tab,value)

             

            2) Ajax solution.

             

            It would be much more simplier to manage this via ajax. You just need bind opened attribute of simple toggle panel and selectedTab attribute of tabPanel to some controller bean properties and manage them as you need with further re-rendering.

            1 of 1 people found this helpful
            • 3. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
              scottaii

              Thank you for the reply,

               

              I am trying the AJAX approach.
              My first step is trying to pop the rich:simpleTogglePanel up via a button.

               

              My button looks like this:

                  <a4j:commandLink

                      value="open"

                      action="#{bean.setToggle(true)}"

                      ajaxSingle="true"

                      reRender="footerTogglePanel"

                      />

               

              My simpleTogglePanel looks like this:

               

              <rich:simpleTogglePanel

                        id="footerTogglePanel"

                        switchType="client"

                        label="TogglePanel"

                        opened="#{bean.isToggle()}">

              // Stuff contained in the toggle panel here //

              <rich:simpleTogglePanel/>

               

              Does this look right?

              • 4. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
                scottaii

                Doesnt seem to be working,

                 

                When i try to reRender the simpleTogglePanel after pressing the button (and setting the opened=true through a bean).

                The info inside the simpleTogglePanel gets re-rendered, but the panel its-self does not pop-up

                Any suggestions?

                • 5. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
                  ilya_shaikovsky
                  which version used? try please latest CR as we had such issues in the past.
                  • 6. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
                    scottaii
                    Cheers for all the help,

                    i opened the rich:simpleTogglePanel using:

                    SimpleTogglePanelManager.toggleOnClient('click ','panelid');

                    and then opened the rich:tab using:

                    RichFaces.switchTab('tabPanelId','tabLabel','tabId')

                    Hope this helps somebody else.
                    • 7. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
                      scottaii
                      Just a quick question.

                      Is there a way of telling which state the toggle panel is in? I.E is it opened or closed?
                      Is there anyway of accessing this?

                      Thank you
                      • 8. Re: rich:simpleTogglePanel - Open/close via a4j:commandLink
                        scottaii

                        Answering my own question.

                         

                        You can use :

                        SimpleTogglePanelManager.panels.get('Id').status

                         

                        to find the status of the rich:simpleTogglePanel e.g is it expanded or collapsed.

                        In my example, i wanted to be able to open the togglePanel via a button, or clicking on the panel

                        but to ONLY beable to close it via the panel (not the button)

                         

                        My JS looked like this:

                         

                        function togglePanelPopUp() {

                                        if(SimpleTogglePanelManager.panels.get('Id').status == "false"){

                                        SimpleTogglePanelManager.toggleOnClient('click ','Id');

                                        }

                         

                        I then switched to a particular tab using:

                        RichFaces.switchTab('tabPanelId','TabLabel','TabId')

                         

                        My a4j:commandLink looked like:

                         

                        <a4j:commandLink value="OpenTogglePanelThenOpenTab"

                                                              ajaxSingle="true"

                                                              immediate="true"

                                                              onclick="togglePanelPopUp(); RichFaces.switchTab('tabPanelId','TabLabel','TabId')"

                                                              reRender="Panelform"/>

                         

                        Again i hope this helps other people,

                        Cheers,

                        Scott