9 Replies Latest reply on Aug 25, 2009 11:22 AM by ilya_shaikovsky

    <rich:panelBar> which one is the selected panelBarItem ?

      Hi !

      I have a panelBar component with several panelBarItem which contain the page "editor.xhtml".
      I wonder if it's possible to inform the backing bean, used in the page "editor.xhtml", which is the selected panelbarItem ?

      mainPage.xhtml

      ...
      <rich:panelBar>
       <rich:panelBarItem label="Item 1">
       <a4j:include viewId="/pages/editor.xhtml"/>
       </rich:panelBarItem>
       <rich:panelBarItem label="Item 2">
       <a4j:include viewId="/pages/editor.xhtml"/>
       </rich:panelBarItem>
      </rich:panelBar>
      ...
      


      editor.xhtml

      ...
      <rich:editor theme="advanced" value="#{bean.text}"/>
      ...


      Thanks for your help :-)

      Chris

        • 1. Re: <rich:panelBar> which one is the selected panelBarItem ?
          nbelaevski

          Hi,

          Try "selectedPanel" attribute.

          • 2. Re: <rich:panelBar> which one is the selected panelBarItem ?

            Ok, I will try.
            Thanks for your help.

            Chris

            • 3. Re: <rich:panelBar> which one is the selected panelBarItem ?

              Unfortunately, it doesn't work. The "selectedPanel" value is always null.
              What did I miss ?

              <rich:panelBar id="panel_bar"
               binding="#{emailParamCtrl.panelBar}">
              
               <rich:panelBarItem id="validation" name="validation">
               <a4j:include viewId="/pages/parametrage/parametrage-editor.xhtml"/>
               </rich:panelBarItem>
              
               <rich:panelBarItem id="remind" name="remind">
               <a4j:include viewId="/pages/parametrage/parametrage-editor.xhtml"/>
               </rich:panelBarItem>
              
              </rich:panelBar>


              • 4. Re: <rich:panelBar> which one is the selected panelBarItem ?
                nbelaevski

                rich:panelBar is switching in client mode only, so it doesn't update server on its state itself; you should add a4j:support or fire request by another means.

                • 5. Re: <rich:panelBar> which one is the selected panelBarItem ?
                  leolo

                   

                  "nbelaevski" wrote:
                  rich:panelBar is switching in client mode only, so it doesn't update server on its state itself; you should add a4j:support or fire request by another means.


                  I'm facing the same issue "how to bring panelBar-client-mode-state-change" to the backing beans.

                  You said, one should add a4j:support, how does this look like?

                  I tried:
                  <rich:panelBar>
                  
                   <a4j:form>
                   <a4j:support action="#{backingBean.panelChanged}" event="onclick"/>
                   </a4j:form>
                  
                   <rich:panelBarItem id="1">...</rich:panelBarItem>
                   <rich:panelBarItem id="2">...</rich:panelBarItem>
                  <rich:panelBar>
                  

                  Doesn't work. The doc of <a4j:support> says, that "wiring with events dynamically attached on the client side is not supported. "

                  Any idea, how I can add a4j:support in this case?

                  Regards, LeoLo


                  • 6. Re: <rich:panelBar> which one is the selected panelBarItem ?
                    ilya_shaikovsky

                    Seems you trying to rely on some kind of magic in your snippet. Support should be pointed to component event. And I'm not sure what could be expected using such code.

                    Actually you should use something like this

                     <rich:panelBar height="400" width="500" selectedPanel="#{userBean.name}">
                     <a4j:support event="onitemchange"/>
                    
                    <b>But</b> thanks to your post next issues was opened:
                    https://jira.jboss.org/jira/browse/RF-7763
                    https://jira.jboss.org/jira/browse/RF-7764
                    
                    Vote for the first one - it will add new event to resolve the state saving problem.
                    


                    • 7. Re: <rich:panelBar> which one is the selected panelBarItem ?
                      ilya_shaikovsky

                      Seems you trying to rely on some kind of magic in your snippet. Support should be pointed to component event. And I'm not sure what could be expected using such code.

                      Actually you should use something like this

                       <rich:panelBar height="400" width="500" selectedPanel="#{userBean.name}">
                       <a4j:support event="onitemchange"/>
                      

                      But thanks to your post next issues was opened:
                      https://jira.jboss.org/jira/browse/RF-7763
                      https://jira.jboss.org/jira/browse/RF-7764

                      Vote for the first one - it will add new event to resolve the state saving problem.

                      • 8. Re: <rich:panelBar> which one is the selected panelBarItem ?
                        leolo

                        voted...so even dumb questions have their right to exist and maybe lead to improvements. :)

                        An easy way for the panelBar-statesaving for me would be the valueChangeListener of rich:panelBar.

                        What is the semantic of this attribute? Is there a meaning behind the behaviour?

                        To me it looks like that the valueChange-Event is always "one change behind" the real change.

                        event.oldValue points to the penultimate panelBarItem, event.newValue points to the lastly clicked panelBarItem, but not to the currently clicked panelBarItem.

                        Is this a bug or a desired behaviour?

                        Regards, LeoLo

                        • 9. Re: <rich:panelBar> which one is the selected panelBarItem ?
                          ilya_shaikovsky

                          the problem that for now only cancelable events fired before switching exist.. So no way to send request after switch performed actually :( Some dirty hacks like combination of setTimeout and jsFunction probably will works but it seems this not a good solution..