Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.

...

Se deben proporcionar métodos de carga lazy (load y count) en el bean de respaldo para manejar la carga de datos según las necesidades de la tabla.

Info
Fundeweb FundeWeb ya proporciona una librería con parte de esta funcionalidad implementada (FundeWebLazyDataModel)

...

Bloque de código
titleDASImpl
public ResultQuery<Entity> obtenerEntities( Map<String, Object> filters, int first, int pageSize, String multiSortMeta ) {
        List<String> restricciones = new ArrayList<>();

        if (filters != null) {
               restricciones = filters.keySet().stream().filter( filtro -> filters.get( filtro ) != null ).map( <<<<<<condiciones a filtrar>>>>>> ).collect( Collectors.toList() );
        }
        return this.resultsByEntityNamedQueryWithDinamicFilter( "obtenerEntities", restricciones, null, first, pageSize, multiSortMeta, null, null );
}


Info

Vease también Consultas con Filtros Dinámicos con diferentes Operadores Lógicos.



Creamos o añadimos a un servicio para manejar la lógica y actuar como intermediario entre el DAS y la capa de presentación con su @Name correspondiente y @Stateles. (@Name( EntityService.ID )@Stateless)

...

Bloque de código
titleMétodos de carga lazy
protected List<Entity> loadPage( int first, int pageSize, List<SortMeta> multiSortMeta, Map<String, Object> filters ) {
               ResultQuery<Entity> resultQuery = getEntityService().obtenerEntity( filters, first, pageSize, null );
               setRowCount( resultQuery.getResultCount().intValue() );
               return resultQuery.getResultList();
        }


Configuramos el bean de respaldo e inicializamos el modelo de datos lazy. (Aquí el servicio si se puede inyectar a través del @name)

Bloque de código
titleManejador
private LazyDataModel<Entity> lazyModel;

@In( value = EntityService.ID, create = true )
private EntityService entityService;

lazyModel = new LazyDataModel( entityService);

...