I read this post very similar to what I would like to ask. However, I tried to solve my problem using the solution to this post, but not successfully. I understand that I can not ask a question in this post. So I would post my code here. (note, if there is no need to create a new message, delete it)
In the application, the user can search, when the user clicks the button, he redirects the user to the results page.
The results page has a computed field and a view. The calculated field is used to display the message if the result was not found in the search result. If the result meets the criteria of the user, the view will display the result.
A view works fine when the result matches the user's choice, but if the result does not match the user's choice, it only displays the view column heading. Therefore, I would like to use the calculated field to show a message to notify the user that the search function has completed and the result is not returned. Otherwise, the user will not know that their search does not return a result.
Here is the code for the results page.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1"></xp:dominoDocument>
</xp:this.data>
<xp:text escape="true" id="computedField1" style="margin-left:200.0px"> </xp:text>
<xp:br></xp:br>
<xp:viewPanel id="viewPanel4" viewStyle="width:600.0px;background- color:rgb(255,255,255);margin-left:200.0px" rows="15">
<xp:this.data>
<xp:dominoView var="view4"
viewName="OfficerDepLoc">
<xp:this.search><![CDATA[#{javascript:var qstring= "";
if ((sessionScope.officerSearch != null && sessionScope.officerSearch != "")|| (sessionScope.depSearch != null && sessionScope.depSearch != "")|| (sessionScope.locSearch != null && sessionScope.locSearch !=""))
{
qstring = " ( FIELD officer contains " + sessionScope.officerSearch + " & FIELD department contains" + sessionScope.depSearch + "& FIELD location contains" + sessionScope.locSearch + ")";
}
var db:NotesDatabase = session.getDatabase("", "myapplication.nsf", false)
var dc:NotesDocumentCollection = db.getAllDocuments();
if (dc.getCount() == 0)
{
qstring = getComponent("computedField1").setValue("After search, there is no record found");
}
return qstring;
}]]></xp:this.search>
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="Officer" id="viewColumn11">
<xp:viewColumnHeader value="officer " id="viewColumnHeader11" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Department" id="viewColumn12">
<xp:viewColumnHeader value="department" id="viewColumnHeader12" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Location" id="viewColumn13">
<xp:viewColumnHeader value="location" id="viewColumnHeader13" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="footerPager" id="pager5">
</xp:pager>
</xp:this.facets></xp:viewPanel>
</xp:view>
When I check the page, I see that the view does not call the calculated field to display the message if the search has no result.
I also tried putting this code in a computed field to show the message, but didn't display anything.
var db:NotesDatabase = session.getDatabase("", "myapplication.nsf", false)
var dc:NotesDocumentCollection = db.getAllDocuments();
if (dc.getCount() == 0)
{
qstring = getComponent("computedField1").setValue("After search, there is no record found");
}
So, I would be interested to know how to display a message if the search has no result? Many thanks.