Class JPALazyDataModel<TT>
java.lang.Object
jakarta.faces.model.DataModel<TT>
org.primefaces.model.LazyDataModel<TT>
com.flowlogix.jeedao.primefaces.JPALazyDataModel<TT>
- Type Parameters:
TT- Data Type
- All Implemented Interfaces:
Serializable, Iterable<TT>, SelectableDataModel<TT>
@Dependent
@InternalQualifierJPALazyModel
public class JPALazyDataModel<TT>
extends LazyDataModel<TT>
Easy implementation of PrimeFaces lazy data model using Lambdas, This is the main class in
com.flowlogix.jeedao.primefaces package
An instance of this class is to be put into your ViewScoped or SessionScoped beans
The implementation is serializable and works with failover to a different server instances
Simple Example:
userviewer.xhtml:
<p:dataTable lazy="true" value="#{userViewer.lazyModel}" var="user">
... specify columns as usual ...
</p:dataTable>
@Named
@ViewScoped
public class UserViewer implements Serializable {
@Inject
@Getter
JPALazyDataModel<UserEntity> lazyModel;
}
Direct Creation Example:
@Named
@ViewScoped
public class UserViewer implements Serializable {
private final @Getter JPALazyDataModel<UserEntity> userModel =
JPALazyDataModel.create(builder -> builder.entityClass(UserEntity.class).build());
}
- Author:
- lprimak
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSerializable builder lambda to easily facilitate creation ofJPALazyDataModelstatic enumused in case-insensitive queries to convert case to lower / upper case -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAutomatic field that's added to the JPA's root object and can be used withgetResultField(String)for result fieldsFields inherited from class LazyDataModel
rowKeyConverter -
Method Summary
Modifier and TypeMethodDescriptionintcount(Map<String, FilterMeta> map) Overridden fromLazyDataModel.count(Map)static <TT> JPALazyDataModel<TT> create(@NonNull JPALazyDataModel.BuilderFunction<TT> builder) Set up this particular instance of the data model with entity manager, class and key converterstatic StringgetResultField(String val) Transforms JPA entity field to format suitable for hints.getRowData(String rowKey) Overridden fromLazyDataModel.getRowData(String)Overridden fromLazyDataModel.getRowKey(Object)initialize(@NonNull JPALazyDataModel.BuilderFunction<TT> builder) Initialize JPA Lazy Data model.Overridden fromLazyDataModel.load(int, int, Map, Map)Methods inherited from class LazyDataModel
getMessage, getPageSize, getRowCount, getRowData, getRowIndex, getRowKeyFromConverter, getWrappedData, isRowAvailable, iterator, iterator, loadOne, recalculateFirst, setPageSize, setRowCount, setRowIndex, setWrappedDataMethods inherited from class DataModel
addDataModelListener, getDataModelListeners, removeDataModelListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
RESULT
Automatic field that's added to the JPA's root object and can be used withgetResultField(String)for result fields- See Also:
-
-
Method Details
-
create
public static <TT> JPALazyDataModel<TT> create(@NonNull @NonNull JPALazyDataModel.BuilderFunction<TT> builder) Set up this particular instance of the data model with entity manager, class and key converter- Type Parameters:
TT- Value Type- Parameters:
builder- serializable lambda for creation- Returns:
- newly-created data model
-
initialize
public JPALazyDataModel<TT> initialize(@NonNull @NonNull JPALazyDataModel.BuilderFunction<TT> builder) Initialize JPA Lazy Data model. Used to set parameters to already-injected instance- Parameters:
builder- serializable lambda for creation- Returns:
- current instance for fluent operations
-
getResultField
-
getRowKey
Overridden fromLazyDataModel.getRowKey(Object)- Specified by:
getRowKeyin interfaceSelectableDataModel<TT>- Overrides:
getRowKeyin classLazyDataModel<TT>
-
getRowData
Overridden fromLazyDataModel.getRowData(String)- Specified by:
getRowDatain interfaceSelectableDataModel<TT>- Overrides:
getRowDatain classLazyDataModel<TT>
-
load
public List<TT> load(int first, int pageSize, Map<String, SortMeta> sortBy, Map<String, FilterMeta> filterBy) Overridden fromLazyDataModel.load(int, int, Map, Map)- Specified by:
loadin classLazyDataModel<TT>
-
count
Overridden fromLazyDataModel.count(Map)- Specified by:
countin classLazyDataModel<TT>
-