Datatable Sorting: problem, workaround and behavior

Components, Ajax Framework, Utilities and More.
Post Reply
Posts: 1
Joined: 09 Jun 2011, 18:03

09 Jun 2011, 18:56

Sorry about my bad english.

Simple table:

Code: Select all

    <p:dataTable var="car" value="#{}">  
        <p:column headerText="Name" sortBy="#{}" >  
            <h:outputText value="#{}" />  

Case 1: Datable with sorting only

Ajax request goes to the server 2 times in the function getCars on load table.

If you try to sort the column, ajax request goes to the server 6 times (on my case) in the function getCars.
Every time that you click on sort, primefaces request data on the server and tables never get sorted.


In fuction getCars do:

Code: Select all

private Cars cars;

public List<Cars> getCars(){

	if (cars == null){
		cars = DATABASE.getCars();
	return cars;
Now primefaces sort the table.

Case 2: Datable with sorting and filter

Ajax request goes to the server 1 time in the function getCars.

If you Do NOT use the filter and then use de sort, primefaces call getCars from server 6 times and no sort effect.

If you use the filter (and clean the filter) and then use de sort, primefaces DO NOT call getCars from server and Sort works.

Case 3: showCase demo.

The demo works because getCars get a variable with initialization on the contructor.
In our model the data came from DataBase everu time that you use table interations ....

What is the real behavior of sort a column? Every time the primefaces goes to the server or not?

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 8 guests