5 Replies Latest reply on Apr 9, 2010 3:45 AM by ilya_shaikovsky

    Panel menu item selected problem

    jsfgeeks

      hi everyone

      in my Application i am using Panel menu,panel menu group and  panel menu item for listing list and sublist.

      i have achived that dynamically through Java Class like below.

       

      //javaimg.JPG

      if (null == biomenu) {
                                  biomenu = (HtmlPanelMenu) app.createComponent(HtmlPanelMenu.COMPONENT_TYPE);
                              }
                              HtmlPanelMenuGroup pnlgrpstd = (HtmlPanelMenuGroup) app.createComponent(HtmlPanelMenuGroup.COMPONENT_TYPE);
      pnlgrpstd.setName(rs_tpview.getString("id"));
                              pnlgrpstd.setId("pnlmenugrp" + rs_tpview.getString("id"));
                              pnlgrpstd.setLabel(rs_tpview.getString("name"));
                              sel_chap = query;
                              rs2_tpview = stmt1_tpview.executeQuery(sel_chap);
                              if (con != null && rs2_tpview != null) {
                                  while (rs2_tpview.next()) {


                                      if (rs_tpview.isFirst() && rs2_tpview.isFirst()) {
                                          current = rs2_tpview.getObject("id");
                                      }
                                      if (rs2_tpview.isFirst()) {
                                          UIParameter pnlstdpara = (UIParameter) app.createComponent(UIParameter.COMPONENT_TYPE);
                                          pnlstdpara.setId("pnlmenuitmfprmchap" + rs2_tpview.getString("id"));
                                          pnlstdpara.setName("std_curr_1stchap");
                                          pnlstdpara.setValue(rs2_tpview.getString("id"));
                                   
                                          pnlgrpstd.getChildren().add(pnlstdpara);
                                      }
                                      HtmlPanelMenuItem phymenuitmchap = (HtmlPanelMenuItem) app.createComponent(HtmlPanelMenuItem.COMPONENT_TYPE);
                                      phymenuitmchap.setLabel(rs2_tpview.getString("name"));
                                      phymenuitmchap.setId("pnlmenuitm" + rs2_tpview.getString("id"));
                                      phymenuitmchap.setName(rs2_tpview.getString("id"));
                                      UIParameter pnlchappara = (UIParameter) app.createComponent(UIParameter.COMPONENT_TYPE);
                                      pnlchappara.setId("pnlmenuitmfprm" + rs2_tpview.getString("id"));
                                      pnlchappara.setName("current");
                                      pnlchappara.setValue(rs2_tpview.getString("id"));
                                      phymenuitmchap.getChildren().add(pnlchappara);
                                      phymenuitmchap.setReRender("outpnl");
                                      phymenuitmchap.setMode("ajax");
                                      Class[] params = {};
                                      MethodExpression actionExpression = app.getExpressionFactory().createMethodExpression(ctx.getELContext(), "#{contentlist.chapterlist_action}", String.class, params);
                                      phymenuitmchap.setActionExpression(actionExpression);
                                  
                                      phymenuitmchap.setReRender("outpnl");
                                      pnlgrpstd.getChildren().add(phymenuitmchap);
                                  
                                  }
                              }

       

                              Class[] params1 = {};
                              MethodExpression actionExpression1 = app.getExpressionFactory().createMethodExpression(ctx.getELContext(), "#{contentlist.std_action}", String.class, params1);
                              pnlgrpstd.setActionExpression(actionExpression1);

       

                              pnlgrpstd.setReRender("pnl_stdchaplst");
                               AjaxContext ac = AjaxContext.getCurrentInstance();
                               ac.addComponentToAjaxRender(biomenu);
                              pnlgrpstd.setExpandMode("ajax");
                              pnlgrpstd.setExpanded(true);
                              biomenu.getChildren().add(pnlgrpstd);

      }
                      }

      //jsp

      <rich:simpleTogglePanel  opened="#{contentlist.search_found==false}"  rendered="#{contentlist.current_subject==1}"  id="smpltglpnl_stdchaplst_bio" style="left:2px;top:35px;position:absolute;width:280px;height:725px;overflow:auto;" switchType="client" >
                                  <f:facet name="header">
                                      <h:outputText id="pnlbio_hd"   value="#{rich:findComponent('btn_bio').value}"/>
                                  </f:facet>
                                      <h:outputText value="#{contentlist.current}"/>
                                  <rich:panelMenu width="255px" selectedChild="#{contentlist.current}" expandSingle="true" binding="#{contentlist.biomenu}" id="biomenu" expandMode="ajax" iconExpandedTopGroup="chevronUp" iconCollapsedTopGroup="chevronDown">
                                  </rich:panelMenu>
                              </rich:simpleTogglePanel>

      I have three buttons and one dropdown for filter purpose so when one click on particular button Panel menu content changes.and first sublist(menu item) get highlighted,

      but when i click on one of list(PanelMenuGroup) then it's first(sublist-panel menu item) won't get highlighted any idea?

       

      like on above image i click on mechanics it's first value get selected!!!!!1

        • 1. Re: Panel menu item selected problem
          ilya_shaikovsky

          not sure that get correctly :/ So on initial rendering(after pmenu constructed) - selectedChild works ok, but after you clicking to menu - it doesn't changed?

           

          P.S. binding object scope?

          • 2. Re: Panel menu item selected problem
            jsfgeeks

            hi,

            thank you very much!!!!

            actually my page scope is session like below

            <managed-bean>
                    <managed-bean-name>contentlist</managed-bean-name>
                    <managed-bean-class>org.my.richfaces.contentlist</managed-bean-class>
                    <managed-bean-scope>session</managed-bean-scope>
                </managed-bean>

            i am also adding Panel menu to ajax context like below

            AjaxContext ac = AjaxContext.getCurrentInstance();
                                     ac.addComponentToAjaxRender(biomenu);

            but still not successfull.

            • 3. Re: Panel menu item selected problem
              ilya_shaikovsky

              actually session scoped JSF component bindigs could cause many problems..

               

              And what about my question, does just further selections after initial rendering not working?

              • 4. Re: Panel menu item selected problem
                jsfgeeks

                thanks,

                sorry i forgot to answer your question.

                Actually When panle menu intially constructed it's first panel menu group's first panel menu item is selected.

                And Even when i click on filter buttons and drop  down to filter it's get selected as i am reconstructing the whole menu on button action event and drop down process value change.

                Problem arises when i clcik on particular menu group so it expanded and it's menu items displayed but it's first menu item wont get selected. at this time i not reconstructing the whole menu i think that might be the problem.

                i have set expandSingle="true"

                • 5. Re: Panel menu item selected problem
                  ilya_shaikovsky

                  Seems got your point. Actually only one item or group is selected in pmenu(that's why attribute called selecvted child - it could be either some item or some group). Selection is not bubled to top - it means if the item selected - parent group is not getting this state visuall. And the same for group if the group selected - nothing gets selected inside. So unfortunatelly seems you need to set expand mode ajax and manage selected child in listener so when node opened - selection became set to it's child.

                   

                  https://jira.jboss.org/jira/browse/RF-8587