omnifaces / optimusfaces

Utility library for OmniFaces + PrimeFaces combined
Other
42 stars 10 forks source link

Add build-in value based paging instead of offset #16

Closed kukel closed 6 years ago

kukel commented 6 years ago

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

BalusC commented 6 years ago

Non-trivial but certainly doable if we use PK.

kukel commented 6 years ago

I already downloaded the source of OptimusFaces to start experimenting. Also for the multi-tenant part

BalusC commented 6 years ago

Added to OmniPersistence in https://github.com/omnifaces/omnipersistence/commit/cd0f318eb2c97c9113eb425920227310106e0678

Edubits commented 6 years ago

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.

Edubits commented 6 years ago

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.

BalusC commented 6 years ago

Fixed and improved in https://github.com/omnifaces/omnipersistence/commit/946e02bc4d20097284c34d008f92b41d0b342b34 and https://github.com/omnifaces/optimusfaces/commit/400223935a27a76e0eeb67b563eef2c919ec0c28