It's subtle...

Try replacing:

> ItemIterable<CmisObject> itemIterable = children.getPage().skipTo(skipCount);

with

> ItemIterable<CmisObject> itemIterable = children.skipTo(skipCount).getPage();


The skipTo() method always creates an iterable over the complete collection. 
The getPage() method can then be used to create an iterable for just a page 
worth of items, starting from the skipTo() point.

Regards,
Dave


On 27 May 2010, at 10:23, Nicolas Raoul wrote:

> Hello all,
> 
> Context: CMIS browsing Java application, using OpenCMIS
> 
> I am trying to use paging to show the files in a folder.
> Below is my attempt to show files 10~15 from a folder that contains 17 files.
> Somehow, it seems to ignore "maxItemsPerPage".
> Am I using the wrong iterator?
> 
> ===== Code =====
> int maxItemsPerPage = 5;
> int skipCount = 10;
> CmisObject object = session.getObject(new ObjectIdImpl(folderId));
> Folder folder = (Folder)object;
> OperationContext operationContext = new OperationContextImpl();
> operationContext.setMaxItemsPerPage(maxItemsPerPage);
> ItemIterable<CmisObject> children = folder.getChildren(operationContext);
> ItemIterable<CmisObject> itemIterable = children.getPage().skipTo(skipCount);
> Iterator<CmisObject> iterator = itemIterable.iterator();
> int count = 0;
> while(iterator.hasNext()) {
>       CmisObject child = iterator.next();
>       count++;
> }
> System.out.println(count);
> System.out.println(children.getPageNumItems());
> System.out.println(children.getTotalNumItems());
> 
> ===== Output =====
> 7
> 5
> 17
> 
> Thanks a lot for your time!
> Nicolas Raoul

Reply via email to