7 Replies Latest reply on Jan 22, 2010 6:53 AM by Dushman Elvitigala


    Dushman Elvitigala Newbie

      I use richfaces with facelets. i created a menu bar using <rich:dropDownMenu> bases on a values stored in a database in a seperate xhtml file.

      I set submit mode of 'ajax' and first time the menu gets rendered corrcetly.

      but when i load a new page in the body area clicking the menu item, all menue items gets dissapered. Only the parent menu is visible

      when submit mode of menuitems were set to 'server', this doesn't happens. i can see all parents and childs.


      can someone shed some light on this?


      thanks in advance,


        • 1. Re: <rich:dropDownMenu>
          Ilya Shaikovsky Master
          please show code snippets.
          • 2. Re: <rich:dropDownMenu>
            Dushman Elvitigala Newbie

            in the menu.xhtml






            <c:forEach items="#{menuItems.menuBar}" var="menu">


            <rich:dropDownMenu binding="#{menu}">









            in the faces config















            in the MenuItemBean.java


            private List menuList;



            public List getMenuBar() {


            if(menuList == null){


            menuList = getMenuComponent();



            return menuList;










            public List<UIComponent> getMenuComponent() {


            GrantedAuthority[] auth = SecurityContextHolder.getContext().getAuthentication().getAuthorities();

            ArrayList<String> buf =

            new ArrayList<String>();


            for (int i = 0; i < auth.length; i++) {



            MenuItemDAO menuItem = (MenuItemDAO) ServiceFinder.findBean(


            List <MenuItem> list = menuItem.getMenuItemByRoles(buf);

            List<UIComponent> menuList =

            new ArrayList<UIComponent>();

            FacesContext ctx = FacesContext.getCurrentInstance();

            Application app = ctx.getApplication();



            for (Object menu : list) {


            HtmlDropDownMenu parent = (HtmlDropDownMenu) app.createComponent(HtmlDropDownMenu.


            parent.setValue(((MenuItem) menu).getItemName());

            parent.setId(((MenuItem) menu).getUiId());

            buildChildMenuItem(parent, ((MenuItem) menu).getChildMenus(), ctx);




            return menuList;





            private UIComponent buildChildMenuItem(UIComponent parent, Set<MenuItem> childs,

            FacesContext context) {



            for (Iterator<MenuItem> iterator = childs.iterator(); iterator.hasNext();) {

            MenuItem menuItem = (MenuItem) iterator.next();



            if (menuItem.getChildMenus().size() == 0) {

            HtmlMenuItem item = (HtmlMenuItem) context.getApplication().createComponent(HtmlMenuItem.






            MethodExpression actionExpression = context.getApplication().getExpressionFactory()

            .createMethodExpression(context.getELContext(),menuItem.getUri(), String.

            class, new Class[]{});



            // String onSelect = "open(this,'" +


            // menuItem.getItemName().toString() + "')";


            // item.setOnselect(onSelect);







            HtmlMenuGroup itemHasChilds = (HtmlMenuGroup) context.getApplication().createComponent(HtmlMenuGroup.





            buildChildMenuItem(itemHasChilds, menuItem.getChildMenus(),context);






            return parent;











            <div id="page">




            <div id="header"><ui:insert name="header">Header</ui:insert></div>




            <div id="menu"><ui:include src="/WEB-INF/includes/menu.xhtml" /></div>




            <div id="navigation"><ui:insert name="navigation">Navigation</ui:insert></div>




            <div id="content"><ui:insert name="content">Content</ui:insert></div>



            <div id="footer"><ui:include src="/WEB-INF/includes/footer.xhtml" /></div>





            thank you showning interest in my question






            • 3. Re: <rich:dropDownMenu>
              Dushman Elvitigala Newbie

              But when i save the page to the file system and view it again. child menuescan be seen.

              I'm using firefox browser

              • 4. Re: <rich:dropDownMenu>
                Ilya Shaikovsky Master
                component bindings should not be session scoped.
                • 5. Re: <rich:dropDownMenu>
                  Dushman Elvitigala Newbie

                  I changed it to request scope. still the problem exists.



                  Attached the screen shots before and after submit.

                  before submit, all child items are poulated.

                  after submit even i move cursor over the file menu child elements are not dispalyed.

                  but when i changed the submit mode to 'server' this works.


                  I used <ui:debug> and inspected view root. there is no diffence in both view roots

                  with refernce to menu components.


                  Any help very much appriciared.



                  • 6. Re: <rich:dropDownMenu>
                    Nick Belaevski Master



                    Check if there are any errors in browser log & a4j:log component.

                    • 7. Re: <rich:dropDownMenu>
                      Dushman Elvitigala Newbie

                      Hi, Nick

                      I did check a4j:log

                      but its empty