How do you execute call lists in JavaServer Faces?

I have a JSF application that I am converting to use web services instead of direct database queries. There are several extremely long lists that used to be easy to return with a simple SQL query. I would like to figure out how to implement paging using JSF / web services. Is there a good template for creating web services with websites?

If that matters, I am currently using the Apache MyFaces link for JSF with Tomahawk extensions (a set of JSF components created by the MyFaces development team prior to its donation to Apache).

+4
source share
5 answers

I like Seam Query objects: http://docs.jboss.com/seam/2.1.0.BETA1/reference/en-US/html_single/#d0e7527

They basically abstract all SQL / JPA in the Seam component, which JSF can easily use.

If you do not want to use Seam and / or JPA, you can implement a similar template.

+2
source

Trinidad has a table component that supports swap, which can help. This is not ideal, but works well enough with Seam, as described in Pete Muir Backing Up Trinidad Data with a Seam Table .

If you do not find any JSF component that you like, you will need to write your own logic to set the parameters for restriction and bias in your EJB-QL (JPA) requests.

+2
source

It depends on whether you want to swap on the client side or on the server side. If the server side, your web services will need to include some additional parameters (for example, "startFrom" and "pageSize"), which will allow you to specify which "page" of the data to be retrieved. You may also need to return the total size of the result so that you can create a paging control.

If you decide that too much effort you can do client side swapping in your bean support (or get the component to do it for you), however this is not recommended if you are talking about thousands of objects!

+2
source

We used the RichFaces Datatable library: http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=usage

It's quite simple, and if you are not using RichFaces yet, it really integrates easily with MyFaces.

+2
source

If you immediately get all the results from the web service and cannot include pagination in the actual web service call, you can try setting the list of elements to a property on the managed bean. You can then associate this with the "value" attribute in the DataTable Tomahawk:

http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataTable.html

and then you can use the DataScroller Tomahawk to paginate the pages stored in this property. Here is the link for this component, it works well with the dataTable component:

http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataScroller.html

You can include this in the dataTable header / footer columns or as a separate component (you will need to specify the dataTable identifier in the "for" attribute of the dataScroller.

Other useful things you can do with a dataTable, such as sorting and switching parts for each row, but can be implemented after you get a basic pagination.

Hope this helps!

+1
source

Source: https://habr.com/ru/post/1276735/


All Articles