Repository navigation
Major release built on OmniPersistence 2.0, whose criteria now behave the same in a lazy and a non-lazy model. It adds support for PrimeFaces 17, entities which need not extend BaseEntity, sorting by multiple columns, and value based paging to any page. Still Java 17, OmniFaces 4.0 and PrimeFaces 15.0.0 at minimum, and tested up to OmniFaces 5.5.8 and PrimeFaces 16.0.2, and with PrimeFaces 17.0.0-M1. Not binary compatible with 1.x: recompile your code against OptimusFaces 2.0 and OmniPersistence 2.0. OptimusFaces 1.x does not run on OmniPersistence 2.0. See "Breaking changes" and the upgrade notes.
Breaking changes
-
Data model
- Requires OmniPersistence 2.0. Its
Pagehas moved toorg.omnifaces.persistence.query, and itsIdentifiableis removed. UsePage.IDinstead ofIdentifiable.ID. #51 #59 - OptimusFaces 1.1 ran on OmniPersistence 1.1, so the breaking changes of OmniPersistence 1.2 apply as well. They affect a custom
PartialResultListLoaderwhich builds or reads aPage: thePageconstructors are private, andPage#getLast()is replaced byPage#getLastOrderingValues(). - The type parameter of
PagedDataModel, itsBuilder,PartialResultListLoader,DynamicCriteria,LazyPagedDataModelandNonLazyPagedDataModelis<E>, no longer bound toIdentifiable, so that a model works for any entity.lazy(BaseEntityService)still requiresBaseEntity. #50 NestedBaseEntityELResolveris renamed toNestedEntityELResolver, because it handles any entity, not only aBaseEntity. It is registered automatically, so this only matters when your code references it. #50 #51
- Requires OmniPersistence 2.0. Its
-
Sorting and paging
PagedDataModel#getOrdering()and theprotectedmethodLazyPagedDataModel#getInitialOrdering()return aList<SortMeta>in order of priority, instead of a singleSortMeta, so that they support sorting by multiple columns via<op:dataTable sortMode="multiple">. #56
Changes in behavior
-
Sorting and paging
- A lazy model shows the elements of a fetched collection, such as the phones of a person, in the order the database gives them. When the table is sorted on a field of that collection, such as
phones.number, they come in that order. Otherwise they come by@OrderByof the collection, else by their natural order. Before, they came in whatever order the persistence provider returned. This comes from OmniPersistence 2.0.
- A lazy model shows the elements of a fetched collection, such as the phones of a person, in the order the database gives them. When the table is sorted on a field of that collection, such as
-
Filtering
- A
nullcriteria on a collection property, such asgroups, matches the rows without elements in a non-lazy model too, where it used to match every row.Not.value(null)matches the rows with elements. For no restriction, leave the criteria out or pass an empty collection. A bound selection which is stillnullneeds a fallback such ascoalesce(selection, emptySet()). #64 - A lazy model inherits the changes in behavior of OmniPersistence 2.0 for
Like,Not,Booland unparseable criteria values. A non-lazy model filters viaCriteria#applies(), which now agrees with the SQL. So both models filter the same, and both ignore accents. See its release notes. NonLazyPagedDataModelthrowsIllegalStateExceptionfor an unknown property in criteria or ordering, instead ofNullPointerException. #50
- A
-
Components and CSS
- With PrimeFaces 17, the CSS classes which
<op:dataTable>and<op:column>add have thep-prefix instead ofui-, the same as those of PrimeFaces 17 itself. So.ui-datatable-actionsbecomes.p-datatable-actions. Adjust your own CSS on these classes when you move to PrimeFaces 17. #65 - The hidden
globalFilterinput of<op:dataTable>is no longer inside.ui-datatable-search, but directly in.ui-datatable-actions. That div no longer has theui-helper-clearfixclass, because its layout is a flexbox now. #66
- With PrimeFaces 17, the CSS classes which
-
Serialization
LazyPagedDataModelno longer serializes the entities of the loaded page and of the selection. After deserialization it loads the same page again, and resolves the selection via the row data loader, else via the criteriaid, else from the loaded page only. So the entities need not beSerializable, and a passivated or replicated session no longer holds them. #53
New features
-
Data model
PagedDataModel.lazy(EntityRepository)andlazy(EntityRepository, PartialResultListLoader): a lazy model for any entity, also one which does not extendBaseEntity. The row key isEntityRepository#getId(E). #50 #54Builder#rowKey(RowKeyGetter)andBuilder#rowData(RowDataLoader): a row key other than the ID, such as.rowKey(YourEntity::getReference).rowData(reference -> service.getByReference(reference)). #50NestedEntityELResolverhandles any class which is or extends an@Entity, such as a DTO subclass of an entity. #50
-
Sorting and paging
<op:dataTable sortMode="multiple">: sort by multiple columns, by a click with Ctrl or Cmd. The query string holds oneoparameter per sorted column, such as?o=gender&o=-email. #56- Value based paging to any page, not only to the page next to the current one. The model caches the ordering values of the loaded pages, and jumps from the nearest one with a residual offset. #48 #49
-
Filtering
- Criteria and ordering on a path through a
Set, such asmembers.name, in a non-lazy model. #64
- Criteria and ordering on a path through a
-
Components and CSS
- PrimeFaces 17 is supported.
ExtendedDataTable#getCssPrefix()returns the CSS class prefix of the PrimeFaces version in use:p-since PrimeFaces 17, elseui-. #65 <op:dataTable>loads a default stylesheet for its header. The global search field and its button form an input group which takes the remaining width, and the export buttons follow on the same line. Your own CSS on the classes listed in thePagedDataModeljavadoc overrides it. #66
- PrimeFaces 17 is supported.
-
Documentation
- The documentation leads with
EntityRepository, and has new sections on the data source and on serialization. #55
- The documentation leads with
Bug fixes
- Components and CSS
<op:dataTable>global search now works on PrimeFaces 16. Before, its search button did nothing, because PrimeFaces 16 widgets no longer have theextend()thatdatatable.jsused to override theDataTablewidget. #52- Column filters work on PrimeFaces 17.0.0-M1. Before, every table rendered "No records found.", and a filter from the query string was applied but its input rendered empty, because PrimeFaces 17 reads the
filterValuebinding of a column back as the source of truth. #68 - A lazy model behind
<p:dataScroller>no longer throwsNullPointerException. Before, the model took its ordering only from the sort metadata of aDataTable. #48
Tested on
The integration tests run on H2, on WildFly 42.0.0 with Mojarra 4.1.13 and Hibernate 7.4.13, GlassFish 8.0.5 with Mojarra 4.1.17 and EclipseLink 5.0.2, and TomEE 10.2.0 with MyFaces 4.0.3 and OpenJPA 4.1.1, all with PrimeFaces 16.0.2. On WildFly they also run with PrimeFaces 15.0.20 and 17.0.0-M1. The SQL is built by OmniPersistence, whose integration tests cover every query shape of OptimusFaces on H2, PostgreSQL, MySQL, SQL Server and DB2. #51 #52 #57 #58 #65
The README lists the known issues.
🤖 Written with Claude Opus 5.5