Menus dinámicos mediante <p:repeat

En el top.xthml

  • usamos <p:repeat>

<b:dropMenu value="#{msg['menu.porclasificacion']}" rendered="#{applicationMenu.cliente.list}">

     <p:repeat value="#{clienteController.clasificacionclienteServices.clasificacionclienteList}" 
               var="itemclasificacion">

           <b:navLink value="#{clienteController.textoPrimerCaracterMayuscula(itemclasificacion.descripcion)}" 

                      outcome="/pages/cliente/list" iconAwesome="fa-print" />

      </p:repeat>   

 </b:dropMenu>

En el controller

  • Definir un List<Entity>

  • En el método get cargar todos los entity

List<Clasificacioncliente> clasificacionclienteList = new ArrayList<>();


    // <editor-fold defaultstate="collapsed" desc="getClasificacionclienteList()">
    public List<Clasificacioncliente> getClasificacionclienteList() {
        try {
            clasificacionclienteList = repository.findAll(new Document("idclasificacioncliente", 1));
        } catch (Exception e) {
            JsfUtil.errorMessage("getClasificacionclienteList() " + e.getLocalizedMessage());
        }
        return clasificacionclienteList;
    }// </editor-fold>

Last updated