By accessing the ?ReadViewEntries url using the MSXML HTTP request, we can do a lookup to a view without reloading the current page. We could also invoke an agent or a servlet to return xml for us and we could do all sorts of processing without ever submitting our page.
This type of web scripting can also be done using XML Data islands, or hidden frames, by I like the HTTP Request object, since it allows us to do a GET or POST request to the server. The downside of this object is that we are limited to IE 5+.
Another alternative is to use a java applet to do the URL operations for us.
To test, simply paste the following code onto a blank domino form, make it all Pass-Thru HTML and open it through a browser.
Code
<script>
function displayViewCategory() {
try {
var doc = document.forms[0];
var view = doc.ViewName.value;
var key = doc.CategoryKey.value;
//get url to current db
var url = location.href.toLowerCase();
url = url.substring(0, url.indexOf(".nsf") + 4);
//append view information to url
url += "/" + view + "?ReadViewEntries&PreFormat";
//append category if the key is not blank
if (key.length > 0) {
url += "&RestrictToCategory=" + key;
}
//use a xmlhttp object to query url (we could use a data island or a hidden frame)
var xmlViewRequest = new ActiveXObject("Microsoft.XMLHttp");
//open url via GET method, not async
xmlViewRequest.open("GET", url, false);
xmlViewRequest.send();
//get the returned xml doc
var entriesDoc = xmlViewRequest.responseXML;
if (entriesDoc == null) {
alert("no entries found.");
return;
}
//access view entries node of the xml document
var entriesNode = entriesDoc.selectSingleNode("viewentries");
//select the actual view entry objects
var entries = entriesNode.selectNodes("viewentry");
//cycle all the entries and generate a message
//note that we simply use the .text property, to get column values we would have to
//dig deeper into the xml dom tree returned from Domino
var msg = "";
for (var i=0; i < entries.length; i++) {
msg += entries(i).text + "n";
}
alert("The following view entries were found: nn" + msg);
return;
} catch (error) {
alert(error.description);
return;
}
}
</script>
<b>Dynamic View Lookup</b>
<table>
<tbody>
<tr>
<td>View:</td>
<td><input type="text" name="ViewName" title="Enter View Name" value=""></td>
</tr>
<tr>
<td>Key:</td>
<td><input type="text" name="CategoryKey" title="Category Name (blank for all entries)" value=""></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Do Lookup" onclick="displayViewCategory();"></td>
</tr>
</tbody>
</table>