Пример #1
0
  @PostConstruct
  public void init() {
    model = new DefaultMenuModel();

    // First submenu
    DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic Submenu");

    DefaultMenuItem item = new DefaultMenuItem("External");
    item.setUrl("http://www.primefaces.org");
    item.setIcon("ui-icon-home");
    firstSubmenu.addElement(item);

    model.addElement(firstSubmenu);

    // Second submenu
    DefaultSubMenu secondSubmenu = new DefaultSubMenu("Dynamic Actions");

    item = new DefaultMenuItem("Save");
    item.setIcon("ui-icon-disk");
    item.setCommand("#{menuView.save}");
    item.setUpdate("messages");
    secondSubmenu.addElement(item);

    item = new DefaultMenuItem("Delete");
    item.setIcon("ui-icon-close");
    item.setCommand("#{menuView.delete}");
    item.setAjax(false);
    secondSubmenu.addElement(item);

    item = new DefaultMenuItem("Redirect");
    item.setIcon("ui-icon-search");
    item.setCommand("#{menuView.redirect}");
    secondSubmenu.addElement(item);

    model.addElement(secondSubmenu);
  }
  /**
   * Gera o menu de disciplinas
   *
   * @param disciplinas
   */
  private void criaMenu(List<Disciplina> disciplinas) {
    menuModel = new DefaultMenuModel();

    DefaultSubMenu submenu = new DefaultSubMenu();
    submenu.setLabel("Alunos/Notas");

    DefaultMenuItem item;
    for (Disciplina disciplina : disciplinas) {
      item = new DefaultMenuItem();
      item.setValue(disciplina.getNome());
      item.setCommand("#{professorAcademicoMB.carregarAlunosDisciplinasPorDisciplinaCursando}");
      item.setParam("id", disciplina.getIdDisciplina());
      item.setIcon("ui-icon-extlink");
      submenu.addElement(item);
    }

    getMenuModel().addElement(submenu);
  }