Interface Sorter<TT>
- Type Parameters:
TT- Entity TypeExample:
@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()); } }
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Sorter Hook
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSort order requested by the UI lives inSorter.MergedSortOrder.requestedSortMeta, Sort order requested by the application lives inSorter.MergedSortOrder.applicationSortOnly one can exist, the other will always be null.static classManipulates sort criteria requested from the UI and possibly adds or replaces it with application-based sort criteria -
Method Summary
Modifier and TypeMethodDescriptionvoidsort(Sorter.SortData sortData, CriteriaBuilder cb, Root<TT> root) Hook for sort criteria manipulation.
-
Method Details
-
sort
Hook for sort criteria manipulation. Application can inspect or remove elements from theSorter.SortData.sortOrdermap and add your own sort order viaSorter.SortData.applicationSort(String, Function)method- Parameters:
sortData- merged sort criteriacb-CriteriaBuilderroot-Root
-