XPages: Error at getNextDocument() from the current one

Hello…

In an XPage, where “doc” is the currently ‘loaded’ document, in a button’s action I would like to obtain a handle to the document that appears under the current in a certain view.

I use the following code, which is generating an error at the last line:


var v:NotesView = database.getView(“ViewByYear”);
var curDoc:NotesDocument = doc.getDocument();

// curDoc = v.getFirstDocument();

if (curDoc==null) return(false);
var nextDoc = v.getNextDocument(curDoc);


The error message is: Script interpreter error, line=11, col=32: [TypeError] Exception occurred calling method NotesView.getNextDocument(lotus.domino.local.Document) null.

if I uncomment the comment line (setting curDoc as the first document in the view), the error does not occur.

Any idea why this is happening? How is the document generated from the context different? This document comes anyway from this same view which is embedded on the same XPage.

Thanks for your insights

Subject: In other words, [NavNext/Prev] in XPages?

A better formulation to my question above:
Is there a way to perform the equivalent of @Command([NavNext]) in an XPage?

I found this thread asking this same question: http://www-10.lotus.com/ldd/xpagesforum.nsf/xpTopicThread.xsp?documentId=CF018691A9A2EBF48525785700663B87 http://www-10.lotus.com/ldd/xpagesforum.nsf/xpTopicThread.xsp?documentId=CF018691A9A2EBF48525785700663B87

Thanks