<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Lazy loading / Data on demand / Paging big tables solution"]]></title>
		<link>http://www.icefaces.org/JForum/posts/list/12.page</link>
		<description><![CDATA[Latest messages posted in the topic "Lazy loading / Data on demand / Paging big tables solution"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi all, I hope this post will ease people the pain when it comes to working with huge data sets. I've done allot of searching, googling and here I present my findings that will hopefully save you some hours. Credits go to Roger at <a href="http://www.ilikespam.com" target="_new" rel="nofollow">www.ilikespam.com</a>. I highly recommend that this sort of stuff should be well documented in IceFaces tutorials and developers guides (untill the planed <ice:richTable> component will come to existence in IceFaces 2.0)

<b>The problem</b>: IceFaces objective is to provide enterprise developers some handy tools when creating some web apps (and does a damn good job at it imo). I (and most likely many others) however found one stone left unturned, in enterprise development it is very common that you have to work with queries that return huge data sets. When you use a ice:dataTable and a ice:dataPaginator to presents this data you'll have to provide the ice:dataTable with a list or an array of objects (business logic objects most of the time). As in my case, creating and returning a list with few thousand entries was simply not an option and probably not for anyone (unless you've got 1337 TB worth of RAM).

<b>Solution</b>: I came across 2 solutions, one much better than the other. I'll not go into much detail of the first one but here's the link to that <a href="http://www.icefaces.org/JForum/posts/list/2895.page" target="_new" rel="nofollow">forum post</a> (note: I did try this one out but couldn't get it to work for me). The other solution is much more simple and makes perfect sense once you realize it. In essence you simply create a new class (LazyLoading.java for example) and make it extend java.util.AbstractList. What you do then is simply "lie" how big the list is because the ice:dataPaginator uses the size() method in the list to find out the entries count. Then you implement your own get(int index) method which loads data as they become needed (when you flip the page). A link to the page with the second method (the elegant and simple one) <a href="http://www.ilikespam.com/blog/paging-large-data-sets-with-a-lazylist" target="_new" rel="nofollow">can be found here!</a>

<b>Exmple of how it works</b>: You've got a page with a <ice:dataTable> and a <ice:dataPaginator> assigned to it with 10 items per page. Your backingbean has a instance of LazyLoadingList (lazyList) which you initialize with a query object, page size and the number of results the query should have returned (this means in fact that you have to do 2x queries every time, however the count(*) query is usually very lite). In the backingbean a instance of LazyLoadingList is returned to the dataTable. The page loads and the LazyLoadingList makes a query for the first 10 items (IceFaces calls lazyList.get(0), ..., lazyList.get(9) to fill in the table). Then lets say you press any page (other than the first) in the dataPaginator, that triggers IceFaces to refresh the dataTable and to fetch new items (somewhat in the lines of lazyList.get(10) for the first item on the second page). The LazyLoadingList get(int index) method checks if it has the requested indexes in range, if it doesn't (a new page) it does a query for it.

<b>My way</b>: Now I did it somewhat different than on the web page I referred to but it was a great starting point for me. What I did different was I made a interface LazyLoadable.java that has the method getUpdatedList(int index, int pageSize) that returns a list and I make my backingbean implement that method. This is the method that actually queries the databae. I do this because I've already got my database related objects initialized there instead of creating them again or passing them as parameters (whatever suits you). In the constructor of LazyLoadingList I take LazyLoadingList(LazyLoadable lazyObject, int pageSize, int numResults). Then instead of a HashTable I used 2x lists. When using this I've a common refresh method in my backingbean (column sort, filter change etc.). So every time something changes this method gets called and in it I recreate the list as follows: 

<li> <i>this.businessObjectList = new LazyLoadingList(this, dataTable.getRows(), myQueryObject.count());</i>

<i>dataTable</i>: is a global HtmlDataTable instance so I define how many rows I want in the .jspx document. <i>myQueryObject.count()</i>: returns how many results the query really returns (could be couple of thousand or whatnot). In addition to this I've the usual getBusinessObjectList() method that gets wired something like this (note: just an example, in practise I've a lot more of them): < ice:dataTable rows="10" value="#{backingbean.businessObjectList}" >

I'll attach those 2x files as attachment and I belive the code speaks for itself (the comments were in Icelandic so I removed them but I've described everything in English here in this post). Feel free ask around and we'll see if I can be of any help. Cheers from Iceland (kinda appropriate we use IceFaces and we're from Iceland don't you think?) -_-


Keywords: <i>lazy loading data on demand paging big tables huge query datapaginator paging</i>]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#35721</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#35721</link>
				<pubDate><![CDATA[Mon, 2 Jun 2008 07:01:04]]> GMT</pubDate>
				<author><![CDATA[ jonsi]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi, I have tried you example (very nice) and pagination works fine. However, with 10 million of rows and a RowSelector, when selecting an item it takes for ever.

If you have a look at RowSelector.java (309) where 

<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>
// ICE-2024: should clear the whole table, not just the displayed page.
if &#40;!getMultiple&#40;&#41;.booleanValue&#40;&#41;&#41; {
   for &#40;int i = 0; i &lt; dataTable.getRowCount&#40;&#41;; i++&#41; {
  if &#40;i != rowIndex&#41; {
  dataTable.setRowIndex&#40;i&#41;;
  setValue&#40;Boolean.FALSE&#41;;
  }
  }
 }</pre>
		</div>

you can see that ICEFaces is iterating all 10 millon of rows to clean the selected value because is calling getRowCount().

Are you selecting a row in your table and it is selected properly?
if not, have you any workaround for this?


]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#38702</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#38702</link>
				<pubDate><![CDATA[Tue, 29 Jul 2008 22:36:48]]> GMT</pubDate>
				<author><![CDATA[ nerlijma]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Sup nerlijma. We checked it out and you're right. 

We are now working on new project where we use a the ice:rowSelector component and uppon inspection we discovered that the RowSlector indeed iterates over the entire list (the LazyLoadingList fetches new rows as they become needed). Not only does it iterate the entire list, it does it quite often (we haven't found a pattern yet but it iterates the list 2 or 3 times). Along with this we did some debugging and also found out that when IceFaces fills in the table it fetches every page 2 times. 

Atm we're trying to figure it out and will post our findings here. Those two projects we're working on were sortof a tryout for IceFaces, while the concept is nice its those practical kinks that makes us less and less likely to adopt it.

cheers, jonsi]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#38728</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#38728</link>
				<pubDate><![CDATA[Wed, 30 Jul 2008 08:20:31]]> GMT</pubDate>
				<author><![CDATA[ jonsi]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ HI all,

Rowselector is not working for me with this lazy pattern too, as nerlijma posted, it is iterating the whole list.

I will post a very simple example to the ICEfaces team to have a look. Huge tables is a quite often requirement !!

best regards]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#38733</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#38733</link>
				<pubDate><![CDATA[Wed, 30 Jul 2008 08:52:07]]> GMT</pubDate>
				<author><![CDATA[ rdefuentes]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ One work-around is to declare your rowSelector as using multiple selection, and then in your selectionListener, enforce the single selection yourself.  This is easiest done when using a smart Map to keep your selections, instead of using a per row field for selection.
]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#38761</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#38761</link>
				<pubDate><![CDATA[Wed, 30 Jul 2008 13:28:18]]> GMT</pubDate>
				<author><![CDATA[ mark.collette]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Mark, 

I have changed RowSelector.java adding a lastRowIndex used only if is not multiple. Also commented where it iterates over all rows and uncommented the old code, where if is not the selected row, rowselector marks it as FALSE.
Therefore, if is not multiple, with every click, old selected index is set to FALSE as well as not clicked ones. Only clicked row index is set to true. 
I am using 16 Million rows dataTable,  with a LazyList pattern, and works perfect. 

<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>
        if &#40;!getMultiple&#40;&#41;.booleanValue&#40;&#41;&#41; {
                dataTable.setRowIndex&#40;lastClickedRow&#41;;
                setValue&#40;Boolean.FALSE&#41;;
                lastClickedRow = rowIndex;
        }
                
                // ICE-2024: should clear the whole table, not just the
                // displayed page.
//                if &#40;!getMultiple&#40;&#41;.booleanValue&#40;&#41;&#41; {
// this code all commented
//                }

            } else {
                // Uncommented this...
                if &#40;Boolean.FALSE.equals&#40;rowSelector.getMultiple&#40;&#41;&#41;&#41; {
                    // Clear all other selections
                    rowSelector.setValue&#40;Boolean.FALSE&#41;;
                }
            }</pre>
		</div>]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#39491</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#39491</link>
				<pubDate><![CDATA[Thu, 14 Aug 2008 09:17:44]]> GMT</pubDate>
				<author><![CDATA[ nerlijma]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Here's a generic version, please review:



public class LazyLoadingList<E> extends AbstractList<E> {
	private LazyLoadable<E> lazyObject;
	private List<E> firstList;
	private List<E> viewList;
	private int currentPage = -1;
	private int numResults;
	private int pageSize;

	public LazyLoadingList(LazyLoadable<E> lazyObject, int pageSize, int numResults) {
		this.lazyObject = lazyObject;
		this.numResults = numResults;
		this.pageSize = pageSize;
	}

	@Override
	public E get(int i) {
		if (i < pageSize) {
			if (firstList == null)
				firstList = lazyObject.getUpdatedList(i, pageSize);
			return (E)firstList.get(i);
		}
		int page = i / pageSize;
		if (page != currentPage) {
			currentPage = page;
			viewList = lazyObject.getUpdatedList(i, pageSize);
		}

		return viewList.get(i % pageSize);
	}

	@Override
	public int size() {
		return numResults;
	}

	public void setNumResults(int numResults) {
		this.numResults = numResults;
	}

}







public interface LazyLoadable<E>
{
	public List<E> getUpdatedList(int index, int pageSize);
}
]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#40308</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#40308</link>
				<pubDate><![CDATA[Sat, 6 Sep 2008 10:39:21]]> GMT</pubDate>
				<author><![CDATA[ bchi49]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ can i have some examples with this lazyloading class being used with data table?]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#40432</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#40432</link>
				<pubDate><![CDATA[Wed, 10 Sep 2008 05:35:34]]> GMT</pubDate>
				<author><![CDATA[ kumareshav]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi.

I need to implement some method to show big tables too. Reading the comments I not sure If you try to implement a paging or something like a live-scroll.

I have found a component in http://www.nitobi.com/products/completeui/demos/explorer/  which show what I need. No matter how many records you have it show as you scroll down/up....

My question is: Work you example as this???

Thanks.

]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#42207</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#42207</link>
				<pubDate><![CDATA[Sun, 26 Oct 2008 11:17:23]]> GMT</pubDate>
				<author><![CDATA[ trumaxformax1]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ I will get back to u once i finished look into this site which you have given.

Thanks]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#42211</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#42211</link>
				<pubDate><![CDATA[Mon, 27 Oct 2008 00:51:45]]> GMT</pubDate>
				<author><![CDATA[ kumareshav]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Ok, thanks.


I'll be waiting.


Greetings]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#42312</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#42312</link>
				<pubDate><![CDATA[Wed, 29 Oct 2008 16:51:45]]> GMT</pubDate>
				<author><![CDATA[ trumaxformax1]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ I have completed a tutorial covering lazy loading a dataTable with JPA and the ICEfaces rendering api. It is located at http://anonsvn.icefaces.org/repo/tutorials/trunk/tutorials/samples/dataTable-JPA.]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#44803</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#44803</link>
				<pubDate><![CDATA[Tue, 6 Jan 2009 11:25:08]]> GMT</pubDate>
				<author><![CDATA[ brad.kroeger]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Here is the proper link, the docs folder has the html page with the tutorial content. The tutorial should be published to icefaces.org in the near future. http://anonsvn.icefaces.org/repo/tutorials/trunk/tutorials/samples/dataTable-JPA]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#44866</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#44866</link>
				<pubDate><![CDATA[Wed, 7 Jan 2009 10:45:29]]> GMT</pubDate>
				<author><![CDATA[ brad.kroeger]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi all.

well  I'm trying Jonsi option to paging a lot of records, it works fine...however when I tryied to log what is the real query running with the database... something happen :S.

I have an DAO object implementing LazyLoadable interface, checking what is the real request I have some log in it to catch every SQL request.. I don't know why.. but every page refresh is requesting all data many times ..and all per groups... let me explain me with my log...

09/01/07 15:32:10 index [0]  pageSize [10]
09/01/07 15:32:10 index [10]  pageSize [10]
09/01/07 15:32:10 index [20]  pageSize [10]
09/01/07 15:32:10 index [30]  pageSize [10]
09/01/07 15:32:10 index [40]  pageSize [10]
09/01/07 15:32:10 index [50]  pageSize [10]
09/01/07 15:32:10 index [60]  pageSize [10]
09/01/07 15:32:10 index [70]  pageSize [10]
09/01/07 15:32:10 index [80]  pageSize [10]
09/01/07 15:32:10 index [90]  pageSize [10]
09/01/07 15:32:10 index [100]  pageSize [10]
09/01/07 15:32:10 index [10]  pageSize [10]
09/01/07 15:32:10 index [20]  pageSize [10]
09/01/07 15:32:10 index [30]  pageSize [10]
09/01/07 15:32:10 index [40]  pageSize [10]
09/01/07 15:32:10 index [50]  pageSize [10]
09/01/07 15:32:10 index [60]  pageSize [10]
09/01/07 15:32:10 index [70]  pageSize [10]
09/01/07 15:32:10 index [80]  pageSize [10]
09/01/07 15:32:10 index [90]  pageSize [10]
09/01/07 15:32:10 index [100]  pageSize [10]
09/01/07 15:32:10 index [10]  pageSize [10]
09/01/07 15:32:10 index [20]  pageSize [10]
09/01/07 15:32:10 index [30]  pageSize [10]
09/01/07 15:32:10 index [40]  pageSize [10]
09/01/07 15:32:10 index [50]  pageSize [10]
09/01/07 15:32:10 index [60]  pageSize [10]
09/01/07 15:32:10 index [70]  pageSize [10]
09/01/07 15:32:10 index [80]  pageSize [10]
09/01/07 15:32:10 index [90]  pageSize [10]
09/01/07 15:32:10 index [100]  pageSize [10]
09/01/07 15:32:10 index [10]  pageSize [10]
09/01/07 15:32:10 index [20]  pageSize [10]
09/01/07 15:32:10 index [30]  pageSize [10]
09/01/07 15:32:10 index [40]  pageSize [10]
09/01/07 15:32:10 index [50]  pageSize [10]
09/01/07 15:32:10 index [60]  pageSize [10]
09/01/07 15:32:10 index [70]  pageSize [10]
09/01/07 15:32:10 index [80]  pageSize [10]
09/01/07 15:32:10 index [90]  pageSize [10]
09/01/07 15:32:10 index [100]  pageSize [10]

I have just 107 records and 10 records per page, I'm not using rowselector.. is just a plane table with pagination... please help :'(]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#44885</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#44885</link>
				<pubDate><![CDATA[Wed, 7 Jan 2009 14:33:50]]> GMT</pubDate>
				<author><![CDATA[ ybendek]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ How the LazyLoadableList Managed bean is processed in the .jspx page ?? Can you give me the code.]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#45314</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#45314</link>
				<pubDate><![CDATA[Mon, 19 Jan 2009 07:43:19]]> GMT</pubDate>
				<author><![CDATA[ meeanaalenoor]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Can you provide the complete example for lazy loading, I am very new to IceFaces.

Thanks]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#54725</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#54725</link>
				<pubDate><![CDATA[Tue, 4 Aug 2009 05:30:56]]> GMT</pubDate>
				<author><![CDATA[ anil7734]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ hi,
can anyone tell me where can i find this RowSelector.java in my project &
which type dataModel is best to use i am currently using CachedRowSetSortableDataModel for database to bean binding.
any help?]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#56086</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#56086</link>
				<pubDate><![CDATA[Sat, 12 Sep 2009 00:40:43]]> GMT</pubDate>
				<author><![CDATA[ jsfgeeks]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi All,
I have a similar problem of ybendek.
It seems that the datatable is colling the get of all the elements. And this happens also when a change the page of the paginator, it reloads all the list.

I don't use any rowselector.

Anyone can help me?

]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#57393</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#57393</link>
				<pubDate><![CDATA[Wed, 21 Oct 2009 04:57:25]]> GMT</pubDate>
				<author><![CDATA[ Overwhelmer]]></author>
			</item>
			<item>
				<title>Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi Guys,

The lazy loading is really nice and work in my project. Thanks for your work.

I have a small problem, as Lazy Loading only load the data in current page, is it possible to do column sort? 

I want to click the header of column and sort the data.

Geoffrey
]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#58175</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#58175</link>
				<pubDate><![CDATA[Wed, 11 Nov 2009 18:00:12]]> GMT</pubDate>
				<author><![CDATA[ flying_3x]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Hi 

I hve a problem with lazy loading big tables we have successfully implemented loading large datasets and then paging them by chunking the datasets now the new problem I encounter is that in my datatable we have a popup component and when the popup component is triggered the whole datatable is refreshed and all the rows from the database are retrieved though I would like it only to refresh that page I am not sure where the problem coud be any help would be appreciated
]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#58373</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#58373</link>
				<pubDate><![CDATA[Wed, 18 Nov 2009 22:49:40]]> GMT</pubDate>
				<author><![CDATA[ priyasubu]]></author>
			</item>
			<item>
				<title>Re:Lazy loading / Data on demand / Paging big tables solution</title>
				<description><![CDATA[ Downloadable source code is different than code from page.]]></description>
				<guid isPermaLink="true">http://www.icefaces.org/JForum/posts/list/8549.page#60982</guid>
				<link>http://www.icefaces.org/JForum/posts/list/8549.page#60982</link>
				<pubDate><![CDATA[Sat, 27 Feb 2010 04:32:43]]> GMT</pubDate>
				<author><![CDATA[ Tostis]]></author>
			</item>
	</channel>
</rss>
