Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count entries in XPages view

My XPage has a view data source with a search formula ("Search in view results") constructed from URL parameters.

The search results are displayed in a repeat control that sits inside a panel. I want to hide this panel if there are no search results and display an appropriate message instead.

The panel is visible based on the following code:

var vec:NotesViewEntryCollection = view1.getAllEntries();
vec.getCount() != 0;

However it seems that getAllEntries returns all entries in the view before the filtering takes place. The Help for AllEntries says "If a view is filtered by FTSearch, this property returns the entries in the filtered view."

Have I misunderstood this? Is there a way that I can get the number of entries AFTER the filtering has taken place?

like image 855
Martin Perrie Avatar asked May 25 '12 09:05

Martin Perrie


1 Answers

When you're accessing the dominoView datasource via SSJS you're not getting the dominoView but the NotesView associated with it. That's why the properties and methods available are for the NotesView class. But the search is being performed on the dominoView datasource front-end not on the NotesView object associated with it.

Instead of using the datasource, get the control that uses it (e.g. A repeat, viewPanel etc) and use the getRowCount() method. This will give you the right total. E.g.

getComponent("repeat1").getRowCount() 
like image 166
Paul Stephen Withers Avatar answered Oct 09 '22 21:10

Paul Stephen Withers