Package org.primefaces.component.menuitem

Examples of org.primefaces.component.menuitem.MenuItem


    writer.startElement("ul", null);
    writer.writeAttribute("id", clientId + "_menu", null);
        writer.writeAttribute("style", "display:none", null);

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

      if(item.isRendered()) {
                writer.startElement("li", null);
                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("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

                .getExpressionFactory();

        for (Assignment assignment : assignmentManager.getAll()) {

            String assignmentTitle = assignment.getTitle();
            MenuItem menuItem = new MenuItem();
            menuItem.setValue(assignmentTitle);

            MethodExpression expression = expressionFactory.createMethodExpression(
                    FacesContext.getCurrentInstance().getELContext(), "#{gradingBean.selectLab('"+ assignmentTitle + "')}", String.class, new Class[]{String.class});

            menuItem.setActionExpression(expression);
            defaultCourse.getChildren().add(menuItem);
        }
        courseView.addSubmenu(defaultCourse);

        FireLogger.logInfo("Constructed courseMenu");
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 styleClass = menuItem.getStyleClass() == null ? "yuimenuitem" : "yuimenuitem " + menuItem.getStyleClass();
       
        writer.startElement("li", null);
        writer.writeAttribute("class", "yuimenuitem", null);
       
        writer.startElement("a", null);
        writer.writeAttribute("href", menuItem.getUrl(), null);
        writer.writeAttribute("class", styleClass, null);
       
        if(menuItem.getStyle() != null) writer.writeAttribute("style", menuItem.getStyle(), null);
        if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
        if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
        if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());
       
        writer.endElement("a");
       
        writer.endElement("li");
       
View Full Code Here

    for (Iterator<UIComponent> iterator = breadCrumb.getChildren().iterator(); iterator.hasNext();) {
      UIComponent child = iterator.next();
     
      if(child.isRendered() && child instanceof MenuItem) {
        MenuItem menuItem = (MenuItem) child;
       
        writer.startElement("li", null);

        writer.startElement("a", null);
        writer.writeAttribute("href", menuItem.getUrl(), null);

        if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
        if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
        if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());

        writer.endElement("a");

        writer.endElement("li");
      }
View Full Code Here

     
        writer.startElement("li", null);
        writer.writeAttribute("class", "yuimenuitem", null);
       
        if(child instanceof MenuItem) {
          MenuItem menuItem = (MenuItem) child;
          encodeMenuItem(facesContext, menuItem);
        } else if(child instanceof Submenu) {
          Submenu childSubmenu = (Submenu) child;
          encodeSubmenu(facesContext, childSubmenu);
        }
View Full Code Here

        // first submenu
        Submenu submenu = new Submenu();
        submenu.setLabel("JavaScript Libraries");

        // menu items
        MenuItem item = new MenuItem();
        item.setValue("jQuery");
        item.setUrl("http://jquery.com");
        submenu.getChildren().add(item);

        item = new MenuItem();
        item.setValue("Yahoo UI");
        item.setUrl("http://yuilibrary.com");
        submenu.getChildren().add(item);

        item = new MenuItem();
        item.setValue("Prototype");
        item.setUrl("http://prototypejs.org");
        submenu.getChildren().add(item);

        model.addSubmenu(submenu);

        // second submenu
        submenu = new Submenu();
        submenu.setLabel("Operations");

        // menu items
        item = new MenuItem();
        item.setValue("Save");
        item.addActionListener(FacesUtil.createMethodActionListener("#{positionedMenuController.save}", Void.class,
                new Class[] { ActionEvent.class }));
        item.setUpdate("growl");
        submenu.getChildren().add(item);

        item = new MenuItem();
        item.setValue("Update");
        item.addActionListener(FacesUtil.createMethodActionListener("#{positionedMenuController.update}", Void.class,
                new Class[] { ActionEvent.class }));
        item.setUpdate("growl");
        submenu.getChildren().add(item);

        item = new MenuItem();
        item.setValue("Delete");
        item.addActionListener(FacesUtil.createMethodActionListener("#{positionedMenuController.delete}", Void.class,
                new Class[] { ActionEvent.class }));
        item.setUpdate("growl");
        submenu.getChildren().add(item);

        model.addSubmenu(submenu);
    }
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 labelStyleClass = menuItem.getStyleClass() == null ? "yuimenuitemlabel" : "yuimenuitemlabel " + menuItem.getStyleClass();
        String icon = menuItem.getIcon() != null ? "background:url(" + getResourceURL(facesContext, menuItem.getIcon()) + ") no-repeat 1%;" : null;
       
        writer.startElement("li", null);
        writer.writeAttribute("class", "yuimenuitem", null);
       
        if(menuItem.getChildCount() > 0) {
          renderChildren(facesContext, menuItem);
        } else {
          writer.startElement("a", null);
          writer.writeAttribute("id", menuItemClientId, null);
          writer.writeAttribute("class", labelStyleClass, null);
         
          if(menuItem.getStyle() != null && icon != null)
            writer.writeAttribute("style", icon + menuItem.getStyle(), null);
          else if(menuItem.getStyle() == null && icon != null)
            writer.writeAttribute("style", icon, null);
          else if(menuItem.getStyle() != null && icon == 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, 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);
          }
         
          //Label is deprecated
          if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());
          if(menuItem.getValue() != null) writer.write((String) menuItem.getValue());
         
          writer.endElement("a");
        }
       
        writer.endElement("li");
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

      if(child.isRendered()) {
        writer.startElement("li", null);
        writer.writeAttribute("class", "yuimenuitem", null);
       
        if(child instanceof MenuItem) {
          MenuItem menuItem = (MenuItem) child;
          encodeMenuItem(facesContext, menuItem, "yuimenuitemlabel");
        } else if(child instanceof Submenu) {
          Submenu childSubmenu = (Submenu) child;
          encodeSubmenu(facesContext, childSubmenu);
        }
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.