5 Replies Latest reply on Aug 3, 2012 7:25 PM by guarf

    RF4 PanelMenuItem (unselectable)

    guarf

      I need the panelMenu items can be clickable but not selected.

       

      I use the panelmenu for navigation. The problem arises when I click an item on the menu and the page have for example an empty inputText with "required = true" that prevents sending the event. Once filled the imputtext, the menuItem which I previously clicked is selected, so I need 2 click to continue: one to deselect and another to re-send the event, do not want to click twice.

       

      any help is greatly appreciated !

        • 1. Re: RF4 PanelMenuItem (unselectable)
          healeyb

          What itemMode and groupMode are you using? The closest I can get to reproducing this is using "server" for both

          attributes (though still not doing what you describe) but it works ok with client and ajax.

           

          I had a similar problem with rich:tabPanel which was cured by using rich:tab immediate="true", you could try

          any mixture of immediate="true" on rich:panelMenu, rich:panelMenuGroup, rich:panelMenuItem.

           

          Regards,

          Brendan.

           

          p.s. it takes a lot of the guess work out of the equation if you post the code.

          • 2. Re: RF4 PanelMenuItem (unselectable)
            guarf

            Thanks Brendan, I'll give more details,

             

            with an empty field, I click to save it in the menu

            http://img35.imageshack.us/img35/585/84282226.jpg

            is selected if the site had a warning message

            http://img835.imageshack.us/img835/6338/82388866.jpg

            I do a click to deselect the item and click again to

            http://img515.imageshack.us/img515/3071/22380972.jpg

            • 3. Re: RF4 PanelMenuItem (unselectable)
              guarf

              The code attached

               

              ---------------------------

              ----------- MENU ----------

              ---------------------------

               

              private void createPanelMenu() {

               

               

                      try {

                          FacesContext context = FacesContext.getCurrentInstance();

                          Application app = FacesContext.getCurrentInstance().getApplication();

                          panelMenu = (UIPanelMenu) app.createComponent(context, UIPanelMenu.COMPONENT_TYPE, "org.richfaces.PanelMenuRenderer");

               

               

                          panelMenu.setId("panelMenuNavigator");// + String.valueOf(System.currentTimeMillis()));

                          panelMenu.setDisabled(false);

                          panelMenu.setExpandSingle(true);

                          panelMenu.setItemClass("menuItemClass");

                          panelMenu.setTopGroupCollapsedRightIcon("triangleDown");

                          panelMenu.setTopGroupExpandedRightIcon("triangleUp");

               

               

                      } catch (Exception e) {

                          Logger.getLogger(ComponentNavigator.class.getName()).log(Level.SEVERE, null, e);

                      }

                  }

               

              ----------------------------

              ----------- GROUP ----------

              ----------------------------

               

               

              private UIPanelMenuGroup createGroup(String strId, String strLabel, List lstComponents, String strAction) {

               

               

                      try {

                          FacesContext context = FacesContext.getCurrentInstance();

                          Application app = FacesContext.getCurrentInstance().getApplication();

                          ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();

                          ELContext elcontext = FacesContext.getCurrentInstance().getELContext();

               

               

                          UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup) app.createComponent(context, UIPanelMenuGroup.COMPONENT_TYPE, "org.richfaces.PanelMenuGroupRenderer");

               

               

                          panelMenuGroup.setId(strId);

                          panelMenuGroup.setLabel(strLabel);

               

               

                          panelMenuGroup.setExpanded(isMenuItemFromGroup(lstComponents));

                          panelMenuGroup.setRender("formBase");

                          panelMenuGroup.setImmediate(true);

                          panelMenuGroup.setExpandEvent("click");

                          panelMenuGroup.setMode(PanelMenuMode.ajax);

               

               

                          MethodExpression methodExpression = expFactory.createMethodExpression(elcontext, "#{componentNavigator." + strAction + "}", null, new Class[0]);

                          panelMenuGroup.setActionExpression(methodExpression);

                          panelMenuGroup.setStyleClass("leftAlign");

               

                          panelMenuGroup.setRendered(renderedGroup(strId));

               

               

                          return loadItems(lstComponents, panelMenuGroup);

                      } catch (Exception e) {

                          Logger.getLogger(ComponentNavigator.class.getName()).log(Level.SEVERE, null, e);

                          return null;

                      }

                  }

               

               

              ---------------------------

              ----------- ITEMS ----------

              ---------------------------

               

               

              while (it.hasNext()) {

                              ComponentDescriptor component = (ComponentDescriptor) it.next();

               

                              strLabel = getMessageResourceString(context.getApplication().getMessageBundle(), component.getId(), null, locale);

               

                              menuItem = (UIPanelMenuItem) app.createComponent(context, UIPanelMenuItem.COMPONENT_TYPE, "org.richfaces.PanelMenuItemRenderer");

                              menuItem.setId(component.getId());

                              menuItem.setLabel(strLabel);

                              menuItem.setLeftIcon(component.getIconImage());

                              menuItem.setExecute("@form");

                              menuItem.setRender("formBase");

                              menuItem.setStyleClass("leftAlign");

                              menuItem.setImmediate(component.getImmediate());

               

                              menuItem.setUnselectable(true);

               

                              if (!renderedMenuItem(component)) {

                                  menuItem.setStyle("display:none");

                              }

               

                              menuItem.setMode(PanelMenuMode.ajax);

               

                              if (component.getId().equalsIgnoreCase(this.lastMenuItem)) {

                                  panelMenu.setActiveItem(component.getId());

                                  panelMenuGroup.setExpanded(true);

                              }

               

               

                              MethodExpression methodExpression = expFactory.createMethodExpression(elcontext, "#{" + component.getAction() + "}", null, new Class[0]);

               

               

                              menuItem.setActionExpression(methodExpression);

                              panelMenuGroup.getChildren().add(menuItem);

                          }

               

               

                          return panelMenuGroup;

              • 4. Re: RF4 PanelMenuItem (unselectable)
                guarf

                any idea ? is the only thing I need to finish the job

                • 5. Re: RF4 PanelMenuItem (unselectable)
                  guarf

                  no way to tell the menuitem to deselect? using javascript?