We’ve got a web application built on JBoss 7.1 with JSF2 and Primefaces 3.3.
On one of our page, there is a ui:repeat displaying 10 items; then the user can click on some kind of “show more” button and 10 more items are displayed through ajax. The user can click the “show more” button until there is no more items to show. Note: This is not pagination, the displayed list gets longer with each click on “show more”.
In fact, when the user clicks on the button, the server returns the old items and the new ones, and the client side of JSF must rebuild the whole repeater through jQuery each time.
We would like to find a better and more performant solution. The old items don’t change between the n-1 and the n call, so it would be more efficient if the server could only return through ajax the 10 new items.
Is it possible in JSF2 ? JSF seems not really compliant with this kind of recursive rendering. The only component that maybe could help us would be a TreeNode component, but it seems a bit of a hack :-/
There’s nothing like that in the standard JSF API.
Also nothing comes to mind in PrimeFaces.For PrimeFaces see the update at the endThe OmniFaces
<o:componentIdParam>may however be exactly what you’re looking for. It allows you to let JSF render only a subset of the component tree based on a specific request parameter, which can be a component ID or a client ID. You could basically just use jQuery’s$.get()to reload the<ui:repeat>along with the start index as a request parameter and use jQuery’s$.append()to append it to the HTML DOM.Here’s a complete kickoff example. The view:
The backing bean:
Update: a live demo can be found in the “Expandable list” example of the
<o:componentIdParam>page of current showcase application.Update 2): PrimeFaces
p:datascrollerhas lazyloading with ‘on demand scrolling’