omnifaces / optimusfaces

Utility library for OmniFaces + PrimeFaces combined

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add build-in value based paging instead of offset

kukel opened this issue · comments

It should be possible to use value based paging in the PrimeFaces LazyDatamodel and it could (if I analyzed the code correctly) be done in a generic way as well just like OptimusFaces currently does for offset based paging. Would be cool to have this.

https://blog.novatec-gmbh.de/art-pagination-offset-vs-value-based-paging/

Maybe I'll try do create something over the weekend and send a pull request

Non-trivial but certainly doable if we use PK.

Added to OmniPersistence in omnifaces/omnipersistence@cd0f318

Nice one! It seems to work, but only if you go from page 1 to 2, to 3, etc. If you go back a page (or jump to a random page) results are not what you would expect. In that case it still uses the values from the last entity on the previous page, even if that page is actually the next page.

I'm also wondering if the following line in BaseEntityService.buildRange()needs brackets around the left side of the &&:
if (hasJoins || page.getOffset() > 0 && page.getLastId() == null)
Otherwise you'll get both the setFirstResult and value based paging together.