A few years ago I was using the DisplayTag library, a very nice library I must add. When doing some coding for a project I had to many records to be in the table. Therefore I used the pagination, that is the moment I ran into problems. I wanted to do the paginations via the hibernate dataaccess layer. The current DisplayTag library does not support that. There are some samples with the HEAD version, I could not get the building process with maven to work. Therefore I started to look around and found a very nice component:
This library includes a very nice view, good paginations backed by server components you can easily write yourself. Therefore I am writing this item, just to show you all how easy it is to do pagination and filtering of your objects in a nicely formatted table.
Actually, I think this is a lot of code, so let's step through it. Lines 9-11 take care of using an external pagination, filtering and sorting. The LimitCallback is used for that purpose. Line 8 shows you the name that can be used as the current item. Have a look at line 19, here you can see we use the order property to obtain the current value for the field order.id. Other interesting stuff, you can switch off filtering and sorting for each column, you can easily format a date field, and you can create your own cell formatters as well. Line 22 shows you how to define them in the jsp. We will show you the code for the formatter as well. But first we'll show you the spring controller that calls the appropriate service.
The Jakarta Bean-Utils package is used to set the values from the filters into the object that is send to the search service. If you enter a value in the lastname box, the searchOrder object will receive this value for lastname so that you can use it in your data access component. The next part of source code does something simular for the ordering.
We created a special object called QueryResultsOrder to hold the field for sorting and the direction in one object.
Now you have all the data to call your service and put back the following to items in the request.
The last part I promised is the formatting of the cell. There is a BaseCell class that you can extend. The only method you need to overwiter is the html() method. There are a lot of utility methods. This method could look like this.
The HtmlBuilder object is used to append all html elements to. Line 4 obtains the style sheet class for the span element to create. Line 6 adds the span element and sets the style attribute class. The span element is also closed in line 6, this way the next text is added after the opening span element. This is done in line 7, and in line 8 the closing span element is added. Actually that is all there is to it. Sounds fun doesn't it?
Hope this helps some of you to get a quick start into the eXtremeComponents
When i 'm listing a drop down box.after that i was select export option then the data is comming into that sheep,after closing that sheep ,i selected the another option from the drop adown box at this time also data is displaying in this sheet.
Please help me how to reset, whe i'll select another option it shoulsd be displayed on the html only.
Thats a great little article you've written. I have the problem of wanting to set the values of the filters to the values used in a previous invocation of the page which I have managed to do using a session variable to hold hte filter values. This works well in terms of actually filtering the result set however I haven't been able to get the table to actually display the fiilter values. Is this possible and if so how would you do this?
GRAVE: Could not create the object [pe.com.vk.asistencia.web.ectable.SelectedUsuarioCell.java]. The class was not found or does not exist.
at java.lang.Class.forName0(Native Method)