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 interface
Serializable builder lambda to easily facilitate creation ofJPALazyDataModel
static enum
used in case-insensitive queries to convert case to lower / upper case -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Automatic field that's added to the JPA's root object and can be used withgetResultField(String)
for result fieldsFields inherited from class org.primefaces.model.LazyDataModel
rowKeyConverter
-
Method Summary
Modifier and TypeMethodDescriptionint
count
(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 String
getResultField
(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 org.primefaces.model.LazyDataModel
getMessage, getPageSize, getRowCount, getRowData, getRowIndex, getRowKeyFromConverter, getWrappedData, isRowAvailable, iterator, iterator, loadOne, recalculateFirst, setPageSize, setRowCount, setRowIndex, setWrappedData
Methods inherited from class jakarta.faces.model.DataModel
addDataModelListener, getDataModelListeners, removeDataModelListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.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:
getRowKey
in interfaceSelectableDataModel<TT>
- Overrides:
getRowKey
in classLazyDataModel<TT>
-
getRowData
Overridden fromLazyDataModel.getRowData(String)
- Specified by:
getRowData
in interfaceSelectableDataModel<TT>
- Overrides:
getRowData
in 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:
load
in classLazyDataModel<TT>
-
count
Overridden fromLazyDataModel.count(Map)
- Specified by:
count
in classLazyDataModel<TT>
-