Class Sorter.SortData
java.lang.Object
com.flowlogix.jeedao.primefaces.Sorter.SortData
Manipulates sort criteria requested from the UI and possibly adds
or replaces it with application-based sort criteria
Example:
@Named
@ViewScoped
public class SortingDataModel implements Serializable {
@Inject
@Getter
JPALazyDataModel<UserEntity> userModel;
@PostConstruct
void initialize() {
userModel.initialize(builder -> builder.sorter((sortData, cb, root) ->
// Example: add an ascending zip code-based sort order
sortData.applicationSort(UserEntity_.zipCode.getName(),
var -> cb.asc(root.get(UserEntity_.zipCode)))
// Example: if user requests zip code-based sort order,
// add address-based sort order to mirror the zip code-based sort order
.applicationSort(UserEntity_.zipCode.getName(), UserEntity_.address.getName(), sortData,
() -> cb.asc(root.get(UserEntity_.address)),
() -> cb.desc(root.get(UserEntity_.address)), () -> null)).build());
}
}
- Author:
- lprimak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReplaces, or adds application sort criteria to the existing UI sort criteria If the sort criteria is new, it is placed at either highest or lowest order, depending on the highPriority parameterapplicationSort
(String sourceFieldName, String fieldName, Sorter.SortData sortData, boolean highPriority, Supplier<Order> ascFn, Supplier<Order> descFn, Supplier<Order> notFoundFn) Helper method to apply application sort criteria based on the UI requested sort criteriaapplicationSort
(String sourceFieldName, String fieldName, Sorter.SortData sortData, Supplier<Order> ascFn, Supplier<Order> descFn, Supplier<Order> notFoundFn) Helper method to apply application sort criteria based on the UI requested sort criteriaReplaces, or adds application sort criteria to the existing UI sort criteria If the sort criteria is new, it is placed at the lowest sort order
-
Constructor Details
-
SortData
-
-
Method Details
-
applicationSort
Replaces, or adds application sort criteria to the existing UI sort criteria If the sort criteria is new, it is placed at the lowest sort order- Parameters:
fieldName
- element to be replaced or addedfp
- lambda to get the application sort criteria- Returns:
- this fluent API
-
applicationSort
public Sorter.SortData applicationSort(String fieldName, boolean highPriority, Function<Optional<SortMeta>, Order> fp) Replaces, or adds application sort criteria to the existing UI sort criteria If the sort criteria is new, it is placed at either highest or lowest order, depending on the highPriority parameter- Parameters:
fieldName
- field to be replaced or addedhighPriority
- integer (starting with zero, highest priority) where this sort directive is put into the array, only if it's inserted, and not modifiedfp
- lambda to get the application sort criteria- Returns:
- this fluent API
-
applicationSort
public Sorter.SortData applicationSort(String sourceFieldName, String fieldName, Sorter.SortData sortData, Supplier<Order> ascFn, Supplier<Order> descFn, Supplier<Order> notFoundFn) Helper method to apply application sort criteria based on the UI requested sort criteria- Parameters:
sourceFieldName
- field to retrieve UI requested sort criteria fromfieldName
- field to be replaced or addedsortData
- current sort dataascFn
- lambda to get ascending sort criteriadescFn
- lambda to get descending sort criterianotFoundFn
- lambda to get sort criteria when UI did not request sorting- Returns:
- this fluent API
-
applicationSort
public Sorter.SortData applicationSort(String sourceFieldName, String fieldName, Sorter.SortData sortData, boolean highPriority, Supplier<Order> ascFn, Supplier<Order> descFn, Supplier<Order> notFoundFn) Helper method to apply application sort criteria based on the UI requested sort criteria- Parameters:
sourceFieldName
- field to retrieve UI requested sort criteria fromfieldName
- field to be replaced or addedsortData
- current sort datahighPriority
- high priority flag, seeapplicationSort(String, boolean, Function)
ascFn
- lambda to get ascending sort criteriadescFn
- lambda to get descending sort criterianotFoundFn
- lambda to get sort criteria when UI did not request sorting- Returns:
- this fluent API
-