Home > Lotus Notes Software, Lotus Notes Tutorial, Notes Designer, Notes Java > Lotus Notes java error “Custom No Documents Found Message”

Lotus Notes java error “Custom No Documents Found Message”

For a recent customer, we were using quite a few views on the web, and there was one view template for all the views. With a couple of the views there was a chance for the view to be empty, which leads to the standard No documents found Domino message. This customer wanted to customize this message. Luckily, the site was for an intranet and all their employees used IE, so the solution was quite a bit easier than what we’ve done in the past.

In the past, we had to hide the HTML that Domino generated, have a flag that says there are no documents, then have some JavaScript to generate our own message if the flag is set. That involves updating the view to stop hiding the HTML that Domino generates (when there are documents) and clear the flag so our own message won’t be generated. With this solution, you just need to update the template. We enhanced the solution to default to the standard Domino way if the browser isn’t IE.

First, don’t make any changes to your view (or “views” in our case, which made this solution more attractive). Just go into the view template. Before the $$ViewBody field, add one line of pass-through HTML:
<div id=”ViewBody” style=”display:block; visibility:visibile;”>

This will put the entire view HTML that Domino generates into its own division, which can be hidden later programmatically if there are no documents in the view. After the $$ViewBody field (which should not be in pass-through HTML), close out that division with a <div> tag.

Next, add a division that will appear if there are no documents. The division will be hidden initially and shown later if needed. To handle Netscape 4, put the division in a hidden layer. This will cause Netscape 4 to use the standard Domino message. Here’s the pass-through HTML you will need:

<layer id=”NoDocumentsFoundParent” style=”display:none;”>
<div id=”NoDocumentsFound” style=”display:block; visibility:hidden;”>
<h1>Hey, there aren’t any documents in this view!</h1>
</div>
</layer>

Obviously, you can put whatever message you want inside the division.

Next comes some JavaScript to programmatically hide the Domino-generated view and show the custom “No Documents Found” message if needed. The JavaScript can appear right on the page so it will run in-line while the page is being generated. It must appear after both the “ViewBody” and the “NoDocumentsFound” divisions, however. Here is the JavaScript:

<script language=”JavaScript” type=”text/javascript”><!–
if ( (document.getElementById) && (document.getElementsByTagName) ) {
var tags = document.getElementById(“ViewBody”).document.getElementsByTagName(“tr”);
} else if (document.all) {
var tags = document.all["ViewBody"].document.all.tags(“tr”);
} else {   // Unknown – don’t use the “No Documents Found” division
var tags = new Array(“x”);
}
if (tags.length == 0) {
if (document.getElementById) {
document.getElementById(“ViewBody”).style.visibility = “hidden”;
document.getElementById(“NoDocumentsFound”).style.visibility = “visible”;
} else if (document.all) {
document.all["ViewBody"].style.visibility = “hidden”;
document.all["NoDocumentsFound"].style.visibility = “visible”;
}
}
//   –>
</script>

Viewed 8387 times by 2159 viewers

  1. No comments yet.
  1. No trackbacks yet.