Mar 15, 2016, 4:52 AM
19 Posts
topic has been resolvedResolved

previous / next buttons to navigate through view

  • Category: Other
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: view,navigation
  • Replies: 3

I have a request to modernize a Domino application with XPages. One of the key features of the application that users can navigate through a set of documents in a notes view via previous and next buttons (opening documents in the order how they appear in the view)

How can I establish similar functionality in XPages?

Mar 15, 2016, 8:11 AM
110 Posts
Repeat control and the pager should help
  1. Use a repeat control
  2. drag a pager but put it outside of the repeat control
    1. customize the pager, attach to = the repeat control, pager style = custom (just put the previous and next)
  3. define a view data source for your repeat control, leave the "bind to" as empty, give the repeat limit = 1, and the collection name = rowdata
  4. drag a panel into the repeat control
  5. go to the panel "data" property and define a document data source for it, select the form that is used by the documents in your repeat control's view data source. make the Default action = Open Document, and compute the Document ID with the following: rowdata.getUniversalID()
  6. go to your Data Pallete. from the list of Data Source, select the document data source. the list of fields available in that form will appear. drag all of them into the panel.
  7. Done.

That should do it.

Mar 15, 2016, 9:05 AM
178 Posts
unique URL

in case you need to create unique URL's (e.g. for bookmarking) you could find the current document in the view and use the getPrevDocument / getNextDocument method

 

                <xp:link escape="true" text="Previous" id="link4"><xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    <xp:this.action>
        <xp:openPage name="/peopleDoc.xsp" target="openDocument">

            <xp:this.documentId><![CDATA[#{javascript:var v:NotesView = database.getView("People");
var doc:NotesDocument = v.getDocumentByKey(person.getDocument().getUniversalID());
if (doc == null) {
    return;
}
else{
    var tmpdoc = v.getPrevDocument(doc);
    doc.recycle();
    doc = tmpdoc;
    return doc.getUniversalID();
}}]]></xp:this.documentId>
        </xp:openPage>
    </xp:this.action></xp:eventHandler></xp:link>

 

In this example the first sorted column is the view contains the document unique id but of course you can create your own "unique key" e.g. firstname + lastname

Mar 15, 2016, 9:12 AM
19 Posts
just what I needed, thank you!