chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Müller <f...@apache.org>
Subject Re: ItemIterable page fetching
Date Wed, 08 Jan 2014 13:06:22 GMT
Hi Dan,

skipTo() and getPage() always create new ItemIterable objects and leave 
the original ItemIterable untouched.
You can derive as many new ItemIterable objects with skipTo() and 
getPage() as you need.


- Florian


> Hello,
> we use ItemIterable for paging through a query result. The data is
> displayed in a grid, page by page and the user can navigate back and 
> forth.
> For the rendering phase we use a code similar to:
> 
> Iterable it = itemITerable.skipTo(offset).getPage(50);
> foreach(Object obj: it) {
> ......
> }
> 
> Now I have to implement a refresh button that would have to refresh the
> currently displayed page (fetch the data again from the server). I know
> that the clean solution is to run the query again and get a new 
> instance
> of ItemIterable and start from the same offset etc. but due to some
> awkward design decisions I am forced to work with the same ItemIterable
> instance and find a workaround.
> 
> I have investigated the implementations of AbstractIterable and
> AbstractIterator (mainly CollectionPageIterable and
> CollectionPageIterator) and found out that a call to getPage() always
> returns a newly created instance of CollectionPageIterable which in 
> turn
> will create a CollectionPageIterator which when requested to iterate
> will fetch the items from the server.
> 
> Is my understanding of the implementation correct?
> Can I assume that the behaviour will stay the same (is part of the
> public API) ?
> 
> Best regards,
> Dan.

Mime
View raw message