问题
I have a search module in my application which filters multiple views, depending on the user choice.
I want to add a dialog if the search has no results, instead of showing the view empty. How can I do this?
I have tried to get rowCount() but it seems it is not getting the right number of rows, I don't know why.
SSJS code:
var vw=database.getView("vwCautareDocI");
var tmpArray = new Array("");
var cTerms = 0;
var dateFormatter = new java.text.SimpleDateFormat( "MM-dd-yyyy" );
if (sessionScope.numprenum) {
tmpArray[cTerms++] = "(Field NumePrenume = \"*" + sessionScope.numprenum + "*\")";
}
if (sessionScope.postvizat) {
tmpArray[cTerms++] = "(Field PostulVizat = \"*" + sessionScope.postvizat + "*\")";
}
if (sessionScope.din && sessionScope.pana) {
tmpArray[cTerms++] = "Field _creationDate >= " + dateFormatter.format(sessionScope.din) + " AND Field _creationDate <= " + dateFormatter.format(sessionScope.pana);
}
filter = tmpArray.join(" AND ").trim();
var vec=vw.getAllDocumentsByKey(filter , true);
return vec.getCount();
This is the filter I use to filter my view. I wanted to add this code to a button, and if the result is 0 then instead of showing the view, it should show a dialog with a message.
回答1:
getAllDocumentsByKey
and fTSearch
methods do different things on the view. You're trying to return the number of entries where the first column matches the full text search criteria you're using. I suspect the view is not categorised on that criteria.
来源:https://stackoverflow.com/questions/26973155/xpages-no-results-after-ftsearch-on-view