Xpages view control - how to select a document and do some action on it

In a view control I need to be able to select a document (by clicking on the row) and then click a button to e.g. display a dijit.Dialog.How can this be done?

Subject: More Info.

Mark posted a good article on this:

Subject: Get selected docs on a view control

You have to retrieve the viewPanel component, the code below show how.

var viewPanel=getComponent(“viewPanel1”);

var docIDs=viewPanel.getSelectedIds();

for(i=0 ; i < docIDs.length ; i++){

var docId = docIDs{i};

var doc:NotesDocument = database.getDocumentByID(docId);

// Process selected documents here

}

I take this code from Dec’s Dom Blog: