Tip

Dynamic XML View Lookup

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.


 <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>

This was first published in July 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.