Skip to content

Choose a tag to compare

@BalusC BalusC released this 02 Dec 12:59
· 2 commits to main since this release
b3da90e

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 Page has moved to org.omnifaces.persistence.query, and its Identifiable is removed. Use Page.ID instead of Identifiable.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 PartialResultListLoader which builds or reads a Page: the Page constructors are private, and Page#getLast() is replaced by Page#getLastOrderingValues().
    • The type parameter of PagedDataModel, its Builder, PartialResultListLoader, DynamicCriteria, LazyPagedDataModel and NonLazyPagedDataModel is <E>, no longer bound to Identifiable, so that a model works for any entity. lazy(BaseEntityService) still requires BaseEntity. #50
    • NestedBaseEntityELResolver is renamed to NestedEntityELResolver, because it handles any entity, not only a BaseEntity. It is registered automatically, so this only matters when your code references it. #50 #51
  • Sorting and paging

    • PagedDataModel#getOrdering() and the protected method LazyPagedDataModel#getInitialOrdering() return a List<SortMeta> in order of priority, instead of a single SortMeta, 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 @OrderBy of the collection, else by their natural order. Before, they came in whatever order the persistence provider returned. This comes from OmniPersistence 2.0.
  • Filtering

    • A null criteria on a collection property, such as groups, 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 still null needs a fallback such as coalesce(selection, emptySet()). #64
    • A lazy model inherits the changes in behavior of OmniPersistence 2.0 for Like, Not, Bool and unparseable criteria values. A non-lazy model filters via Criteria#applies(), which now agrees with the SQL. So both models filter the same, and both ignore accents. See its release notes.
    • NonLazyPagedDataModel throws IllegalStateException for an unknown property in criteria or ordering, instead of NullPointerException. #50
  • Components and CSS

    • With PrimeFaces 17, the CSS classes which <op:dataTable> and <op:column> add have the p- prefix instead of ui-, the same as those of PrimeFaces 17 itself. So .ui-datatable-actions becomes .p-datatable-actions. Adjust your own CSS on these classes when you move to PrimeFaces 17. #65
    • The hidden globalFilter input of <op:dataTable> is no longer inside .ui-datatable-search, but directly in .ui-datatable-actions. That div no longer has the ui-helper-clearfix class, because its layout is a flexbox now. #66
  • Serialization

    • LazyPagedDataModel no 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 criteria id, else from the loaded page only. So the entities need not be Serializable, and a passivated or replicated session no longer holds them. #53

New features

  • Data model

    • PagedDataModel.lazy(EntityRepository) and lazy(EntityRepository, PartialResultListLoader): a lazy model for any entity, also one which does not extend BaseEntity. The row key is EntityRepository#getId(E). #50 #54
    • Builder#rowKey(RowKeyGetter) and Builder#rowData(RowDataLoader): a row key other than the ID, such as .rowKey(YourEntity::getReference).rowData(reference -> service.getByReference(reference)). #50
    • NestedEntityELResolver handles 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 one o parameter 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 as members.name, in a non-lazy model. #64
  • Components and CSS

    • PrimeFaces 17 is supported. ExtendedDataTable#getCssPrefix() returns the CSS class prefix of the PrimeFaces version in use: p- since PrimeFaces 17, else ui-. #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 the PagedDataModel javadoc overrides it. #66
  • Documentation

    • The documentation leads with EntityRepository, and has new sections on the data source and on serialization. #55

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 the extend() that datatable.js used to override the DataTable widget. #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 filterValue binding of a column back as the source of truth. #68
    • A lazy model behind <p:dataScroller> no longer throws NullPointerException. Before, the model took its ordering only from the sort metadata of a DataTable. #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