12 Replies Latest reply on Apr 1, 2008 1:27 PM by Val Blant

    panelMenu questions

    Val Blant Newbie

      Hello. I am very new to Richfaces (just downloaded it) and I am evaluating it to see if I should use it on my next project. I really liked what I saw on the demo page, so I hope to be able to use it.

      The first component I tried was panelMenu. Unfortunately it didn't work entirely as expected, so I have a couple of questions:

      1) Is there a way to have an empty panelMenuGroup act as if it was a panelMenuItem? This would be useful to me for such menu items as, say, 'Home'. If I use an actual panelMenuItem, it stands out too much from all of the other top level groups I have in the menu. panelMenuGroup seems to have an action='' attribute, but it doesn't work.

      2) Is there a way to preserve the state of the menu when navigating from page to page? I did see the 'selectedChild' attribute and it does select the item with the given name, but it does not expand the necessary groups to show the item! This feels like a bug, since there is no sense in selecting a nested item, if we are not going to expand the parent groups to show it...


      Thanks.

        • 1. Re: panelMenu questions
          Jens Mueller Novice

           

          "vace117" wrote:
          2) Is there a way to preserve the state of the menu when navigating from page to page?


          I did that by property bindung, which means i create, design, save its state and obtain the menu from a backing bean:

          if (panelMenu == null)
          {
          this.panelMenu = new HtmlPanelMenu();

          /* --- First PanelMenuGroup --- */
          HtmlPanelMenuGroup menuGroup_1 = new HtmlPanelMenuGroup();
          menuGroup_1.setLabel("LABEL_1");
          menuGroup_1.setName("MenuGroup_1");
          menuGroup_1.setIconCollapsed("triangle");
          menuGroup_1.setIconExpanded("triangleDown");
          menuGroup_1.setId("menuGroup_1");

          /* --- First PanelMenuItem --- */
          HtmlPanelMenuItem menuItem_1_1 = new HtmlPanelMenuItem();
          menuItem_1_1.setLabel(rb.getString("LABEL_1_1"));
          menuItem_1_1.setName("menuItem_1_1");
          menuItem_1_1.setStyleClass("navigation-menu-item"); menuItem_1_1.setActionExpression(createMethodExpression("someaction"));
          ...
          public MethodExpression createMethodExpression (String target)
          {
          MethodExpression methodExpression = FacesContext.getCurrentInstance().getApplication().getExpressionFactory(). createMethodExpression(FacesContext.getCurrentInstance().getELContext(), target, null, new Class<?>[0]);
          return methodExpression;
          }
          public void setPanelMenu(HtmlPanelMenu panelMenu)
          {
          this.panelMenu = panelMenu;
          }


          public HtmlPanelMenuItem getSelectedItem()
          {
          return selectedItem;
          }

          public void setSelectedItem(HtmlPanelMenuItem selectedItem)
          {
          this.selectedItem = selectedItem;
          }

          hope it helps a bit getting into all that weird stuff ;)

          • 2. Re: panelMenu questions
            Jens Mueller Novice

            ...bean must be session scoped of course!

            • 3. Re: panelMenu questions
              Val Blant Newbie

              Thanks, Jason12. Binding the panelMenu component to a session scoped bean is a good idea and it looks like it works.

              I looked a bit deeper into exactly what the action and actionListener attributes on panelMenuGroup do and it looks like there is a bug there (or I am missing something). UIPanelMenuGroup class implements ActionSource, which allows it to be a source of ActionEvents. So if I specify an action="" attribute for my panelMenuGroup the ActionEvent is queued as it should, except that UIInput from which UIPanelMenuGroup inherits doesn't know how to process ActionEvents! I am talking about this line in UIInput:

               public void broadcast(FacesEvent event)
               throws AbortProcessingException
               {
               if (!(event instanceof ValueChangeEvent))
               {
               throw new IllegalArgumentException("FacesEvent of class " + event.getClass().getName() + " not supported by UIInput");
               }
              


              Since event is an ActionEvent, the above code blows up. How can this possibly work? It is, however, difficult to believe that no one ever tested the action attribute on panelMenuGroup :), so I am probably doing something wrong. Can anyone comment?

              Thanks.

              P.S. Just so its clear, here is exactly what I am doing:
              <rich:panelMenu mode="server" binding="#{menuBackingBean.htmlPanelMenu}">
               <rich:panelMenuGroup expandMode="server" label='Home' action="#{menuBackingBean.homeMenuAction}" />
               ...etc...
              


              • 4. Re: panelMenu questions
                Val Blant Newbie

                Hmm, I guess this is more of a developer's forum question.... I think I will commit the sin of cross posting in this case :)

                • 5. Re: panelMenu questions
                  Jens Mueller Novice

                  Hi vace117, i would definitely help if i could! i'm myself struggling with an issue regarding the panelmenuitem and actionlistener (which doesn't seem to work and which apparently hasn't been tested by anybody before ;) good luck

                  • 6. Re: panelMenu questions
                    Val Blant Newbie

                    Incidentally, I was able to work around the problem by using

                    <rich:panelMenuItem styleClass="dr-pmenu-top-group" ...etc
                    


                    and overriding:
                    .rich-pmenu-top-item-label {
                     font-weight: bold;
                     font-family: Arial, Verdana, sans-serif;
                     font-size: 11px;
                     color: #FFF;
                    }
                    

                    in my css.

                    This effectively makes the item look like a group, so it works the way I want it to.

                    Still would be nice to get to the bottom of the action attribute not working...

                    • 7. Re: panelMenu questions
                      Ilya Shaikovsky Master

                      checked at 3.2.0 GA. (demosite sample)

                      just chnaged one of the groups to

                       <rich:panelMenuGroup label="Group 1" action="#{panelMenu.updateCurrent}" expandMode="ajax">
                       <f:param name="current" value="Just Group"/>
                      

                      and it works for me. Action called, panel updated.

                      • 8. Re: panelMenu questions
                        Alexander Belov Novice

                        Have anybody tried to use <rich:panelMenu> (RichFaces 3.2.0 GA) in Firefox 2.0.0.13 (Windows XP SP2)? No labels are displayed in menu. It works in IE, Safari.

                        • 9. Re: panelMenu questions
                          Ilya Shaikovsky Master

                          I've checked demosite on FF and IE. looks like I see the same for both browsers.

                          • 10. Re: panelMenu questions
                            <todo> <todo> Newbie

                            This is a code to reproduce:

                            <rich:panelMenu mode="none" expandSingle="true" event="none" expandMode="none" id="menu"
                            binding="#{menuBean.menuComponent}" style="margin-right:10px">
                             <rich:panelMenuGroup expanded="true" label="#{core.menuHeaderLabel}">
                             <c:forEach items="#{menuBean.menuItems}" var="menuItem">
                             <rich:panelMenuItem label="#{menuItem.label}" icon="triangle" name="#{menuItem.value}">
                             <a4j:support reRender="#{menuBean.navigateRerender}" limitToList="true" ajaxSingle="true"
                             event="onclick" ignoreDupResponses="true" action="#{menuBean.selectMenuItem}">
                             <f:param name="menuItemValue" value="#{menuItem.value}"/>
                             </a4j:support>
                             </rich:panelMenuItem>
                             </c:forEach>
                             </rich:panelMenuGroup>
                             </rich:panelMenu>


                            • 11. Re: panelMenu questions
                              Alexander Belov Novice

                              Fixed by custom setting:

                              .dr-pmenu-top-group-div
                              {
                              overflow:visible;
                              }

                              Thanks.

                              • 12. Re: panelMenu questions
                                Val Blant Newbie

                                To follow up on the action attribute not working on panelMenuGroup...

                                Turns out that it works with JSF-RI and doesn't work with MyFaces due to lack of event type checking in UIInput.

                                Details are here: http://jboss.com/index.html?module=bb&op=viewtopic&t=132787