Xpages no results after FTSearch on view

匆匆过客 提交于 2019-12-11 09:36:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!