1. Description: Web browser clients are often directed to a view that may not contain any documents. This might be because no documents meet the selection criteria or the database uses reader names fields to control which documents the user can see. When using the web browser client to open a Domino view which has no documents the web user sees a page which shows "No documents found" with no other information or other navigation tools.
To learn more about web development use the following links:
Beginner R5 Domino Web Application Development
Web browser clients are often directed to a view that may not contain any documents. This might be because no documents meet the selection criteria or the database uses reader names fields to control which documents the user can see. When using the web browser client to open a Domino view which has no documents the following message is displayed:
This message can be confusing to the user. To reduce confusion, replace the default "No documents found" message with a custom message like the following:
Follow these step to replace the "No documents found" message with a custom message:
Create a view template form to act as a container and provide formatting for the view. In this example the view name is "North" so the name of the view template form must be "$$ViewTemplate for North".
Add these fields to the view template form (put the ViewName and Count field at the top of the form and hide them at all times):
Код:
Field name
Type
Formula
ViewName
Text. Computed for display
@Subset(@ViewTitle;-1)
Count
Text. Computed for display
@Elements(@DbColumn("Notes":"NoCache";@DbName;ViewName;1))
$$ViewBody
Editable
None
NoDocsMessage
Text. Computed for display
@If(Count = 0; "No customers are located in the North region."; "")
In the ViewName field formula, @ViewName returns the list of view names and view alias names. The @Subset function is used to return the last name or alias in the list.
In the Count field formula, @DbColumn returns the list of values from the first column in the view. The @Elements function operates on this list to return the number of documents in the view to the Count field. So, if a view has no documents to display, the Count field will contain 0 (zero).
The $$ViewBody field is used to position the view for display in the view template form.
The @If formula in the NoDocsMessage field tests the Count field and displays the custom message when there are no documents to display.
Hide the $$ViewBody field when Count field is equal to zero using the hide paragraph formula shown in this image:
4. When you use a view template Domino does not provide the standard set of navigation links to page forward or backward, expand or collapse the view, or search the view. At a minimum, add view navigation links to page forward and backward using @DbCommand("Domino";"ViewNextPage") and @DbCommand("Domino";"ViewPreviousPage") commands.
This techique has one limitation. @DbColumn will return an error when it returns more than about 55KB of information. Try to make the column number you specify be a column in the view that has minimal information (preferably a text constant like "a".) Otherwise, the form will return an error when your user opens a really big view. One addition that could be done is to use @IsError to trap for errors if the @DbColumn returned one because the view was too big. If there was an error, then just set the Count field equal to a number greater than zero so the view contents will display.
------------------------------------------------------------------------------------------------------
2.
в форме обрамляешь вьюху тегом <div id="divEmbeddedView">view</div>
в форме, в JS Header пишешь:
Код
Код:
function CheckNoDocuments()
{
if (document.getElementById("divEmbeddedView").innerHTML.indexOf("No documents found") > 0)
{
document.getElementById("divEmbeddedView").innerHTML = ""
};
}
в форме, в onLoad: CheckNoDocuments();
естественно, нужно, чтобы броузер пользователей позволял отрабатывать JS скриптам
-----------------------------------------------------------------------------------------------------------
3.
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 java script:
Код:
<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");
}
-----------------------------------------------------------------------------------------------------