Package org.primefaces.component.menuitem

Examples of org.primefaces.component.menuitem.MenuItem


     */
    public MenuBean() {
        model = new DefaultMenuModel();

        //Home + Profile
        MenuItem item = new MenuItem();
        item.setValue("Home");
        item.setIcon("ui-icon-home");
        if ((returnRole("11")) || (returnRole("12"))) {
            item.setUrl(this.getURL("userHome"));
        }
        if (returnRole("21")) {
            item.setUrl(this.getURL("accountAll"));
        }

        if (returnRole("22")) {
            item.setUrl(this.getURL("superHome"));
        }
        model.addMenuItem(item);

        //set profile for applicant and authorizer only
        if (returnRole("11") || returnRole("12")) {
            item = new MenuItem();
            item.setValue("Profile");
            item.setIcon("ui-icon-person");
            item.setUrl(this.getURL("travelProfileView"));

            model.addMenuItem(item);
        }

        //Applications
        if (returnRole("11")) {
            Submenu appMenu = new Submenu();
            appMenu.setLabel("Applications");
            appMenu.setIcon("ui-icon-note");

            item = new MenuItem();
            item.setValue("Start New Application");
            item.setUrl(this.getURL("applicationCreate"));
            appMenu.getChildren().add(item);

            model.addSubmenu(appMenu);
        }
        //Authorization

        if (returnRole("12")) {                //AUTHORIZER
            Submenu authMenu = new Submenu();
            authMenu.setLabel("Authorizations");
            authMenu.setIcon("ui-icon-circle-check");

            item = new MenuItem();
            item.setValue("Manage Authorizations");
            item.setUrl(this.getURL("authorizerHome"));
            authMenu.getChildren().add(item);
            model.addSubmenu(authMenu);
        }

        if (returnRole("22")) {
            Submenu superMenu = new Submenu();
            superMenu.setLabel("Actions");
            superMenu.setIcon("ui-icon-wrench");

            item = new MenuItem();
            item.setValue("Create Admin");
            item.setUrl(this.getURL("createAdmin"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Edit Admin");
            item.setUrl(this.getURL("editAdminSelect"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Create Role");
            item.setUrl(this.getURL("createRole"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Deactivate Account");
            item.setUrl(this.getURL("deactivateAccount"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Department Handler");
            item.setUrl(this.getURL("departmentHandler"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);
        }

    }
View Full Code Here


      if(child.isRendered()) {
        writer.startElement("li", null);
        writer.writeAttribute("class", "ui-menu-item ui-corner-all", null);
       
        if(child instanceof MenuItem) {
          MenuItem menuItem = (MenuItem) child;
          encodeMenuItem(facesContext, menuItem, "ui-menu-item-label ui-corner-all");
        } else if(child instanceof Submenu) {
          Submenu childSubmenu = (Submenu) child;
          encodeSubmenu(facesContext, childSubmenu);
        }
View Full Code Here

    ResponseWriter writer = facesContext.getResponseWriter();
    String position = dock.getPosition();
   
    for(UIComponent child : dock.getChildren()) {
      if(child instanceof MenuItem && child.isRendered()) {
        MenuItem menuitem = (MenuItem) child;
        String clientId = menuitem.getClientId(facesContext);
       
        String styleClass = "pf-dock-item-" + position;
        if(menuitem.getStyleClass() != null) {
          styleClass = styleClass + " " + menuitem.getStyleClass();
        }
       
        writer.startElement("a", null);
        writer.writeAttribute("id", menuitem.getClientId(facesContext), null);
        writer.writeAttribute("class", styleClass, null);
       
        if(menuitem.getStyle() != null) writer.writeAttribute("style", menuitem.getStyle(), null);
       
        if(menuitem.getUrl() != null) {
          writer.writeAttribute("href", getResourceURL(facesContext, menuitem.getUrl()), null);
          if(menuitem.getOnclick() != null) writer.writeAttribute("onclick", menuitem.getOnclick(), null);
          if(menuitem.getTarget() != null) writer.writeAttribute("target", menuitem.getTarget(), null);
        } else {
          writer.writeAttribute("href", "javascript:void(0)", null);
         
          UIComponent form = ComponentUtils.findParentForm(facesContext, menuitem);
          if(form == null) {
            throw new FacesException("Dock must be inside a form element");
          }
         
          String formClientId = form.getClientId(facesContext);
          String command = menuitem.isAjax() ? buildAjaxRequest(facesContext, menuitem, formClientId, clientId) : buildNonAjaxRequest(facesContext, menuitem, formClientId, clientId);
         
          command = menuitem.getOnclick() == null ? command : menuitem.getOnclick() + ";" + command;
         
          writer.writeAttribute("onclick", command, null);
        }
       
        if(position.equalsIgnoreCase("top")) {
View Full Code Here

   
    writer.write(var + ".addItems([");
   
    for(UIComponent child : menu.getChildren()) {
      if(child instanceof MenuItem && child.isRendered()) {
        MenuItem item = (MenuItem) child;
        String menuItemClientId = item.getClientId(facesContext);
        String onclick = item.getOnclick();
       
        if(!firstMenuitem)
          writer.write(",");
        else
          firstMenuitem = false;
       
        writer.write("{");
        writer.write("text:'" + (String) item.getValue() + "'");
       
        if(item.getUrl() != null) {
          writer.write(",url:'" + getResourceURL(facesContext, item.getUrl() + "'"));
          if(item.getTarget() != null) writer.write(",target:'"+ item.getTarget() + "'");
          if(onclick != null) writer.write(",onclick:{fn:function() {" + onclick + "}}");
        } else {
          if(form == null) {
            throw new FacesException("ContextMenu : '" + menu.getClientId(facesContext) + "' must be inside a form element");
          }
          String formClientId = form.getClientId(facesContext);
         
          String command = item.isAjax() ? buildAjaxRequest(facesContext, item, formClientId, menuItemClientId) : buildNonAjaxRequest(facesContext, item, formClientId, menuItemClientId);
          command = onclick == null ? command : onclick + ";" + command;
         
          writer.write(",onclick:{fn: function() {" + command + "}}");
        }
       
View Full Code Here

   
    for(Iterator<UIComponent> iterator = submenu.getChildren().iterator(); iterator.hasNext();) {
      UIComponent child = (UIComponent) iterator.next();
     
      if(child instanceof MenuItem && child.isRendered()) {
        MenuItem menuItem = (MenuItem) child;
        String menuItemClientId = menuItem.getClientId(facesContext);
        String defaultLabelStyleClass= "ui-menu-item-label";
        String labelStyleClass = menuItem.getStyleClass() == null ? defaultLabelStyleClass : defaultLabelStyleClass + " " + menuItem.getStyleClass();
        String icon = menuItem.getIcon() != null ? "background:url(" + getResourceURL(facesContext, menuItem.getIcon()) + ") no-repeat 1%;" : null;
        String style = menuItem.getStyle();
       
        if(style != null && icon != null)
          style =  icon + style;
        else if(style == null && icon != null)
          style = icon;
       
        writer.startElement("li", null);
        writer.writeAttribute("class", "ui-menu-item ui-corner-all", null);
       
        if(menuItem.shouldRenderChildren()) {
          renderChildren(facesContext, menuItem);
         
        } else {
          writer.startElement("a", null);
          writer.writeAttribute("id", menuItemClientId, null);
          writer.writeAttribute("class", labelStyleClass, null);
          if(style != null) writer.writeAttribute("style", style, null);
         
          if(menuItem.getUrl() != null) {
            writer.writeAttribute("href", getResourceURL(facesContext, menuItem.getUrl()), null);
            if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
            if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
           
          } else {
            writer.writeAttribute("href", "javascript:void(0)", null);
           
            UIComponent form = ComponentUtils.findParentForm(facesContext, submenu);
            if(form == null) {
              throw new FacesException("Menu must be inside a form element");
            }
           
            String formClientId = form.getClientId(facesContext);
            String command = menuItem.isAjax() ? buildAjaxRequest(facesContext, menuItem, formClientId, menuItemClientId) : buildNonAjaxRequest(facesContext, menuItem, formClientId, menuItemClientId);
           
            command = menuItem.getOnclick() == null ? command : menuItem.getOnclick() + ";" + command;
           
            writer.writeAttribute("onclick", command, null);
          }
         
          if(menuItem.getValue() != null) writer.write((String) menuItem.getValue());
         
          writer.endElement("a");
        }
       
        writer.endElement("li");
View Full Code Here

     */
    public MenuBean() {
        model = new DefaultMenuModel();

        //Home + Profile
        MenuItem item = new MenuItem();
        item.setValue("Home");
        item.setIcon("ui-icon-home");
        if ((returnRole("11")) || (returnRole("12"))) {
            item.setUrl(this.getURL("userHome"));
        }
        if (returnRole("21")) {
            item.setUrl(this.getURL("accountAll"));
        }

        if (returnRole("22")) {
            item.setUrl(this.getURL("superHome"));
        }
        model.addMenuItem(item);

        //set profile for applicant and authorizer only
        if (returnRole("11") || returnRole("12")) {
            item = new MenuItem();
            item.setValue("Profile");
            item.setIcon("ui-icon-person");
            item.setUrl(this.getURL("travelProfileView"));

            model.addMenuItem(item);
        }

        //Applications
        if (returnRole("11")) {
            Submenu appMenu = new Submenu();
            appMenu.setLabel("Applications");
            appMenu.setIcon("ui-icon-note");

            item = new MenuItem();
            item.setValue("Start New Application");
            item.setUrl(this.getURL("applicationCreate"));
            appMenu.getChildren().add(item);

            model.addSubmenu(appMenu);
        }
        //Authorization

        if (returnRole("12")) {                //AUTHORIZER
            Submenu authMenu = new Submenu();
            authMenu.setLabel("Authorizations");
            authMenu.setIcon("ui-icon-circle-check");

            item = new MenuItem();
            item.setValue("Manage Authorizations");
            item.setUrl(this.getURL("authorizerHome"));
            authMenu.getChildren().add(item);
            model.addSubmenu(authMenu);
        }

        if (returnRole("22")) {
            Submenu superMenu = new Submenu();
            superMenu.setLabel("Actions");
            superMenu.setIcon("ui-icon-wrench");

            item = new MenuItem();
            item.setValue("Create Admin");
            item.setUrl(this.getURL("createAdmin"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Edit Admin");
            item.setUrl(this.getURL("editAdminSelect"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Create Role");
            item.setUrl(this.getURL("createRole"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Deactivate Account");
            item.setUrl(this.getURL("deactivateAccount"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);
           
            item = new MenuItem();
            item.setValue("Reactivate Account");
            item.setUrl(this.getURL("reactivateAccount"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Department Handler");
            item.setUrl(this.getURL("departmentHandler"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);
        }

    }
View Full Code Here

     */
    public MenuBean() {
        model = new DefaultMenuModel();

        //Home + Profile
        MenuItem item = new MenuItem();
        item.setValue("Home");
        item.setIcon("ui-icon-home");
        item.setUrl("#");

        model.addMenuItem(item);


        item = new MenuItem();
        item.setValue("Profile");
        item.setIcon("ui-icon-person");
        item.setUrl(this.getURL());

        model.addMenuItem(item);

       
        //Submenu 
        Submenu submenu = new Submenu();
        submenu.setLabel("Applications");
        submenu.setIcon("ui-icon-note");

        item = new MenuItem();
        item.setValue("Start New Application");
        item.setUrl("#");
        submenu.getChildren().add(item);

        item = new MenuItem();
        item.setValue("Manage Applications");
        item.setUrl("#");
        submenu.getChildren().add(item);

        model.addSubmenu(submenu);
    }
View Full Code Here

    ResponseWriter writer = facesContext.getResponseWriter();
    String position = dock.getPosition();
   
    for(UIComponent child : dock.getChildren()) {
      if(child instanceof MenuItem && child.isRendered()) {
        MenuItem menuitem = (MenuItem) child;
        String clientId = menuitem.getClientId(facesContext);
       
        String styleClass = "ui-dock-item-" + position;
        if(menuitem.getStyleClass() != null) {
          styleClass = styleClass + " " + menuitem.getStyleClass();
        }
       
        writer.startElement("a", null);
        writer.writeAttribute("id", menuitem.getClientId(facesContext), null);
        writer.writeAttribute("class", styleClass, null);
       
        if(menuitem.getStyle() != null) writer.writeAttribute("style", menuitem.getStyle(), null);
       
        if(menuitem.getUrl() != null) {
          writer.writeAttribute("href", getResourceURL(facesContext, menuitem.getUrl()), null);
          if(menuitem.getOnclick() != null) writer.writeAttribute("onclick", menuitem.getOnclick(), null);
          if(menuitem.getTarget() != null) writer.writeAttribute("target", menuitem.getTarget(), null);
        } else {
          writer.writeAttribute("href", "javascript:void(0)", null);
         
          UIComponent form = ComponentUtils.findParentForm(facesContext, menuitem);
          if(form == null) {
            throw new FacesException("Dock must be inside a form element");
          }
         
          String formClientId = form.getClientId(facesContext);
          String command = menuitem.isAjax() ? buildAjaxRequest(facesContext, menuitem) : buildNonAjaxRequest(facesContext, menuitem, formClientId, clientId);
         
          command = menuitem.getOnclick() == null ? command : menuitem.getOnclick() + ";" + command;
         
          writer.writeAttribute("onclick", command, null);
        }
       
        if(position.equalsIgnoreCase("top")) {
View Full Code Here

        //menu
        writer.startElement("ul", null);
    writer.writeAttribute("id", menuId, null);

    for(UIComponent child : button.getChildren()) {
      MenuItem item = (MenuItem) child;

      if(item.isRendered()) {
                writer.startElement("li", item);
                encodeMenuItem(context, item);
                writer.endElement("li");
      }
    }
View Full Code Here

     */
    public MenuBean() {
        model = new DefaultMenuModel();

        //Home + Profile
        MenuItem item = new MenuItem();
        item.setValue("Home");
        item.setIcon("ui-icon-home");
        if ((returnRole("11")) || (returnRole("12"))) {
            item.setUrl(this.getURL("userHome"));
        }
        if (returnRole("21")) {
            item.setUrl(this.getURL("accountAll"));
        }

        if (returnRole("22")) {
            item.setUrl(this.getURL("superHome"));
        }
        model.addMenuItem(item);

        //set profile for applicant and authorizer only
        if (returnRole("11") || returnRole("12")) {
            item = new MenuItem();
            item.setValue("Profile");
            item.setIcon("ui-icon-person");
            item.setUrl(this.getURL("travelProfileView"));

            model.addMenuItem(item);
        }

        //Applications
        if (returnRole("11")) {
            Submenu appMenu = new Submenu();
            appMenu.setLabel("Applications");
            appMenu.setIcon("ui-icon-note");

            item = new MenuItem();
            item.setValue("Start New Application");
            item.setUrl(this.getURL("applicationCreate"));
            appMenu.getChildren().add(item);

            model.addSubmenu(appMenu);
        }
        //Authorization

        if (returnRole("12")) {                //AUTHORIZER
            Submenu authMenu = new Submenu();
            authMenu.setLabel("Authorizations");
            authMenu.setIcon("ui-icon-circle-check");

            item = new MenuItem();
            item.setValue("Manage Authorizations");
            item.setUrl(this.getURL("authorizerHome"));
            authMenu.getChildren().add(item);
            model.addSubmenu(authMenu);


        }

        if (returnRole("22")) {
            Submenu superMenu = new Submenu();
            superMenu.setLabel("Actions");
            superMenu.setIcon("ui-icon-wrench");

            item = new MenuItem();
            item.setValue("Create Admin");
            item.setUrl(this.getURL("createAdmin"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Edit Admin");
            item.setUrl(this.getURL("editAdminSelect"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Deactivate Account");
            item.setUrl(this.getURL("deactivateAccount"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Reactivate Account");
            item.setUrl(this.getURL("reactivateAccount"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);

            item = new MenuItem();
            item.setValue("Department Handler");
            item.setUrl(this.getURL("departmentHandler"));
            superMenu.getChildren().add(item);
            model.addSubmenu(superMenu);
        }

        if (!returnRole("11")) {
            //Go on leave
            item = new MenuItem();
            item.setValue("Go On Leave");
            item.setIcon("ui-icon-calendar");
            item.setUrl(this.getURL("leaveHome"));

            model.addMenuItem(item);
        }
       
        if (returnRole("21")) {
            //Go on leave
            item = new MenuItem();
            item.setValue("Change Application Stages");
            item.setIcon("ui-icon-transfer-e-w");
            item.setUrl(this.getURL("customStages"));

            model.addMenuItem(item);
        }
    }
View Full Code Here

TOP

Related Classes of org.primefaces.component.menuitem.MenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.