voyent
Pageable and sortable table for large data sets  XML
Forum Index -> General Help
Author Message
atomz4peace

Joined: 20/Nov/2006 00:00:00
Messages: 121
Offline


Hi,

Using the component examples I could make a pageable and sortable table with a session-persistent backing bean. This works fine but leaves me with 2 questions I'm wondering if anyone has good solutions for.

1) The simple one is what if my data in the database changes mid-session? Can I put an expiration time on the data. I know I can use java time/date/calendar to make my own simple expire timer, but does icefaces have support already?

2) This is the big one. I have some reports that may pull a couple thousand rows from the database and use them to populate the same number of resulting business objects.

This is a bit slow on the DB to do the full query, but more importantly, uses lots of memory.

So my question is does icefaces have any built-in support for retrieving data from the DB as I need it? I know that I have to write the backing bean myself (which I did for the main query), but does anyone have sample code or logic to make it simpler.

In my session bean, can I get the values from ICE about how many rows per page and what page I'm on so that I can write the DB query correctly to get the right data? I know that writing partial queries would break the whole SortableList support but does anyone have any good solutions?

Thanks!
Jim
bionut

Joined: 25/Apr/2006 00:00:00
Messages: 41
Offline


I have several ICEFaces webapps in production use on an Internet facing website and have several ICEFaces dataTables which are paged from a large database. The ICEFaces mail application is what I patterned my dataTables after. I used facelets as the view technology, Spring, and Hibernate (for persistance). Attached you should find the facelets page and the corresponding backing beans for a page which contains a paged dataTable. I would attach a screenshot but it would show sensitive information (user accounts). The table has a search filter along the top edge which permits the user to specify subsetting info for the Hibernate query.

Oops this board only permits two file attachements, I'll attach the other two files via a subsequent reply message.
 Filename OrderListBean.java [Disk] Download
 Description Backing bean for dataTable
 Filesize 9 Kbytes
 Downloaded:  1459 time(s)

 Filename orders.xhtml [Disk] Download
 Description Facelets page
 Filesize 7 Kbytes
 Downloaded:  1243 time(s)

[Email]
bionut

Joined: 25/Apr/2006 00:00:00
Messages: 41
Offline


Attached you should fine the remaining two Java classes for the previously mentioned ICEFaces webapp.
 Filename OrderBean.java [Disk] Download
 Description Backing bean which represents a row in the dataTable.
 Filesize 2 Kbytes
 Downloaded:  1084 time(s)

 Filename PagedListDataModel.java [Disk] Download
 Description Superclass of OrderListBean, this class was copied from the ICEFaces mail sample application. There is another class (DataPage) which is used in this webapp and that class was also copied from the ICEFaces mail sample application.
 Filesize 5 Kbytes
 Downloaded:  1277 time(s)

[Email]
bionut

Joined: 25/Apr/2006 00:00:00
Messages: 41
Offline


OK, I ran a screenshot, of the above mentioned ICEFaces webapp, through my digital shredder and attached it to this post.
[Thumb - orders.png]
 Filename orders.png [Disk] Download
 Description Screenshot
 Filesize 330 Kbytes
 Downloaded:  1095 time(s)

 Filename DataPage.java [Disk] Download
 Description Remaining Java class which was copied from ICEFaces mail sample webapp.
 Filesize 1 Kbytes
 Downloaded:  1045 time(s)

[Email]
atomz4peace

Joined: 20/Nov/2006 00:00:00
Messages: 121
Offline


Thank you very much. That's the idea is was looking for! It was the whole dealing with first and last page and row that was the tricky part. I'll give it a shot and see if it's as easy as you made it look.

Jim
hurzeler

Joined: 13/Dec/2006 00:00:00
Messages: 33
Offline


I just noticed that the UIData component calls the setRowIndex(int index) method one too many times. As a consequence the fetchPage method in getRowData gets called twice (in: } else if (rowIndex >= endRow))

Lets say you have 10 rows in the table the rowIndex will go from 0 to 10 (that is actually 11 and not 10).

Hence here is the question: Why does the UIData component need to call the setRowIndex method number of rows in the table + 1???

Any ideas? It really screws up a nice piece of code. Thanks guys.
amerk

Joined: 30/Jan/2007 00:00:00
Messages: 6
Offline


I also noticed that the setRowIndex is called 11 times for a pagesize of 10. The Reason is a bug in Icefaces 1.5.3. It is fixed in Version 1.6.0.

Workaround for developers using version 1.5.3:

In the class "com.icesoft.faces.component.ext.renderkit.TableRenderer" method "encodeChildren":
- Remove line 336-339:

if ((numberOfRowsToDisplay > 0) &&
(countOfRowsDisplayed >= numberOfRowsToDisplay)) {
break;
}

- Replace line 440-442:
rowIndex++;
countOfRowsDisplayed++;
uiData.setRowIndex(rowIndex);

with:

rowIndex++;
countOfRowsDisplayed++;
if ((numberOfRowsToDisplay > 0 &&
countOfRowsDisplayed >= numberOfRowsToDisplay) ||
(rowIndex >= uiData.getRowCount())) {
break;
}
uiData.setRowIndex(rowIndex);


Question to IceSoft:
Can I copy the code in the class "TableRenderer:encodeChildren" from Version 1.6.0 to the Version 1.5.3 or can you create a patch?

Thanks
Alex
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team