| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 20/11/2006 23:34:50
|
atomz4peace
Joined: 20/11/2006 00:00:00
Messages: 106
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
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 21/11/2006 07:20:44
|
bionut
Joined: 25/04/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 |
Download
|
| Description |
Backing bean for dataTable |
| Filesize |
9 Kbytes
|
| Downloaded: |
1024 time(s) |
| Filename |
orders.xhtml |
Download
|
| Description |
Facelets page |
| Filesize |
7 Kbytes
|
| Downloaded: |
840 time(s) |
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 21/11/2006 07:26:43
|
bionut
Joined: 25/04/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 |
Download
|
| Description |
Backing bean which represents a row in the dataTable. |
| Filesize |
2 Kbytes
|
| Downloaded: |
675 time(s) |
| Filename |
PagedListDataModel.java |
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: |
820 time(s) |
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 21/11/2006 07:36:04
|
bionut
Joined: 25/04/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.
|
| Filename |
orders.png |
Download
|
| Description |
Screenshot |
| Filesize |
330 Kbytes
|
| Downloaded: |
791 time(s) |
| Filename |
DataPage.java |
Download
|
| Description |
Remaining Java class which was copied from ICEFaces mail sample webapp. |
| Filesize |
1 Kbytes
|
| Downloaded: |
686 time(s) |
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 21/11/2006 13:04:25
|
atomz4peace
Joined: 20/11/2006 00:00:00
Messages: 106
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
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 17/12/2006 02:48:09
|
hurzeler
Joined: 13/12/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.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 27/03/2007 08:58:34
|
amerk
Joined: 30/01/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
|
|
|
 |
|
|