1 Reply Latest reply on Aug 2, 2010 5:57 AM by Ilya Shaikovsky

    How to Navigate When i click Root menu???

    Siva P Master

      Hi all,

       

      I have problem with navigation when i click root menu.I have to set the HtmlActionParameter for the rootmenu like "Home".When i click home i should navigate through next page.

      I have attached images with this post.If any one come out with this issue help me.Thank you.

       

      Image:

      menuwithsub.bmp

      My Bean Class:

       

      I have all the setter,getter for methods.The area marked with the "RED" color is what i am trying to set the action for the root menu.Like when i click "Home".For menuItem only we can able to

      setActionExpression,but for
      HtmlDropDownMenu how to set action.

       

       

       

       

      public void formMainMenu()
      {
      List cache = null;
      List menuList =null;
      try
      {
      log.debug("Before Menu:"+cache);
      //Call the db to get all the menu Items
      cache = ServiceDao.menuListExecute().findByExample();
      log.info("Result From DB for Menu...."+cache.size());
      menuList = engineRichMenu(cache);
      if(menuList!=null && menuList.size()>0)
      {
      //Set the Home Menu
      setHomeMenu((HtmlToolBar)menuList.get(0));
      //Set the New Registration Menu
      setNewRegistrationMenu((HtmlToolBar)menuList.get(1));
      //Set the Existing Customer Menu
      setExistCustomerMenu((HtmlToolBar)menuList.get(2));
      //Set the Bill Payment
      setBillPaymentMenu((HtmlToolBar)menuList.get(3));
      //Set the Sales Collection
      setSalesCollectionMenu((HtmlToolBar)menuList.get(4));
      //Set the data Entry
      setDataEntryMenu((HtmlToolBar)menuList.get(5));
      //Set the IInd Level Verification 
      setSecondLevelVerificationMenu((HtmlToolBar)menuList.get(6));
      //Set the Bulk Transaction
      setBulkTransactionMenu((HtmlToolBar)menuList.get(7));
      //Set the Reporting
      setReportingMenu((HtmlToolBar)menuList.get(8));
      //Set the Other Servicing
      setOtherServicingMenu((HtmlToolBar)menuList.get(9)); 
      //Set the Log Out
      setLogoutMenu((HtmlToolBar)menuList.get(10));
      }
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      finally
      {
      cache = null;
      log.debug("finally:"+cache);
      }
      }

      private List engineRichMenu(List cache) throws Exception
      {
      int i = 0;
      log.debug("Begin engineRichMenu....");
      List menuList = new ArrayList();
      Menu menu =null;
      while(i<cache.size())
      {
      menu = (Menu)cache.get(i);
      log.debug(" Menu ...."+menu.getLabel());
      log.debug(" menu.getParent() ...."+menu.getParent().intValue());
      log.debug(" menu.getStatus() ...."+menu.getStatus());
      if ((menu.getParent().intValue() == 0) && !menu.getStatus().equals("ADDED"))
      {
      HtmlToolBar toolbar = new HtmlToolBar();  
      HtmlDropDownMenu rootMenu = new HtmlDropDownMenu();  
      rootMenu.setValue(menu.getLabel());  
      rootMenu.setLabelClass("celcomMenuLabel");
      rootMenu.setStyleClass("celcomMenuLabel");
      rootMenu.setDirection("bottom-right");
      rootMenu.setHorizontalOffset(10);
      rootMenu.setJointPoint("tr");
      menu.setStatus("ADDED");

      //HtmlMenuItem menuItems= new HtmlMenuItem();
      //menuItems.setValue(menu.getLabel());
      HtmlActionParameter rootmenuItemParam = new HtmlActionParameter();
      rootmenuItemParam.setId("includePage"+Integer.toString(menu.getSerial()));
      rootmenuItemParam.setName("includePage");
      rootmenuItemParam.setValue(menu.getAction());
      log.debug("Root Menu ActionParam:"+menu.getAction());
      //Class[] params = {};                
              //FacesContext ctx = FacesContext.getCurrentInstance(); 
              //Application app = ctx.getApplication();
              //MethodExpression actionExpression = app.getExpressionFactory().createMethodExpression(ctx.getELContext(),"#{menuActionBean.actionInclude}",String.class, params);
              //menuItems.setActionExpression(actionExpression);

      cache.set(i,menu);
      log.debug(" Before getting Childrennnnnnnnnn");

      //rootMenu.getChildren().add(menuItems);//Adding Root Menus Action param

      List childMenu = recursiveChildRichMenu(cache,menu.getSerial());
      log.debug(" child size...."+childMenu.size());
      rootMenu.getChildren().addAll(childMenu);
      toolbar.getChildren().add(rootMenu);
      menuList.add(toolbar);
      log.debug(" menuListALL..."+menuList);
      }
      else
      {
      log.debug("Menu Already adddedddd");
      }
      i++;
      }
      log.debug("End engineRichMenu...menuList............."+menuList.size());
      return menuList;
      }

      private List recursiveChildRichMenu(List recursiveData,Integer parentID) throws Exception
      {
      int beforeI;
      List parentMenuList = new ArrayList();;
      HtmlMenuItem parentMenu = null;
      HtmlMenuGroup parentGroupMenu = null;
      List childMenu;
      int i = 0;
      Menu menu=null;
      while (i < recursiveData.size())
      {
      menu = (Menu)recursiveData.get(i);
      if ((menu.getParent() == parentID.intValue()) && !menu.getStatus().equals("ADDED"))
      {
      parentMenu = richMenuInfo(menu);
              HtmlActionParameter menuItemParam = new HtmlActionParameter();
              menuItemParam.setId("includePage"+Integer.toString(menu.getSerial()));
              menuItemParam.setName("includePage");
              menuItemParam.setValue(menu.getAction());
      parentMenu.getChildren().add(menuItemParam);
      parentMenu.setReRender("contentPage");
      parentGroupMenu = richMenuGroupInfo(menu);
      menu.setStatus("ADDED");
      recursiveData.set(i, menu);
      beforeI = i;  
      childMenu = recursiveChildRichMenu(recursiveData, menu.getSerial());
      if(childMenu.size()>0){
              //log.debug(whiteSpace(tabSpaces)+"Child Found = "+childMenu.size());
              parentMenuList.add(parentGroupMenu);
              parentGroupMenu.getChildren().addAll(childMenu);
              parentMenu = null;
         }else{
              //log.debug(whiteSpace(tabSpaces)+"No Child Found... ");
              Class[] params = {};  
        
              FacesContext ctx = FacesContext.getCurrentInstance(); 
              Application app = ctx.getApplication();
              MethodExpression actionExpression = app.getExpressionFactory().createMethodExpression(ctx.getELContext(),"#{menuActionBean.actionInclude}",String.class, params);
              log.debug("Else loop-");
              parentMenu.setActionExpression(actionExpression);  
        
         parentMenuList.add(parentMenu);
      parentGroupMenu = null;
         }
      }
      i++;
      }
      return parentMenuList;
      }
      private HtmlMenuItem richMenuInfo(Menu menu)
      {
      HtmlMenuItem htmlMenuItem = new HtmlMenuItem();
      htmlMenuItem.setValue(menu.getLabel()); 
      htmlMenuItem.setSubmitMode("ajax");
      htmlMenuItem.setRendered(true);
      htmlMenuItem.setAjaxSingle(true);
      htmlMenuItem.setLabelClass("celcomMenuLabel");
      htmlMenuItem.setStyleClass("celcomMenuLabel");
      return htmlMenuItem;
      }
      private HtmlMenuGroup richMenuGroupInfo(Menu menu) {
      HtmlMenuGroup htmlMenuGroup = new HtmlMenuGroup();
      htmlMenuGroup.setValue(menu.getLabel()); 
      htmlMenuGroup.setLabelClass("celcomMenuLabel");
      htmlMenuGroup.setStyleClass("celcomMenuLabel");
      return htmlMenuGroup;
      }