Wednesday, August 02, 2006

?ReadViewEntries

With Ajax becoming a must have for web applications, many Domino developers have come to see the importance and worth of Domino's XML capabilities.
The ReadViewEntries URL command was added to the code stream in the 5.0.2 release of Notes and Domino. It allows a view to be represented purely as XML.

The Domino Designer help document, URL commands for opening servers, databases, and views, is full of great info on the various URL commands for Domino elements. However, I wanted to have this be a resource for just the ReadViewEntries command. Below I will give examples of its use and limitations.
Please note: I wrote this from my own experiences. This is in no way is to be considered an IBM information source.

URL command for reading views as XML - ?ReadViewEntries

The following applies to all databases under the notes/data directory on a Domino server. Hidden design elements are hidden from the server too; you can’t use Domino URL commands to access documents in hidden views. Domino's security model applies. If a user is allowed to see a document, then it will be listed as an entry. Keep this in mind when designing all Domino databases. Hiding documents is not security. Utilize ACLs, Element access, and document level security. Don't rely on $ViewTemplates, they do not apply to views being requested as XML via ReadViewEnries.

In many ways the ReadViewEntries command works the same as the OpenView command. ReadViewEntries can be applied to view and folder elements with additional parameters that allow for control of the data set. In the example below, simply replace 'ReadViewEntries' with 'OpenView" in the URL, to get a better look at the request. That being said, searching a view and having the results returned as XML is not available at this time. The Query parameter will be ignored when used in conjunction with ReadViewEntries.

The results from the ReadViewEntries command is well formed XML. The schema for this and all Domino elements can be found in the notes\xmlschemas directory of any Domino or Notes install.

Caution: If the database property "Do Not Allow URL Open" is set, URL commands are disabled.

Basic Structure

http://www.macguidera.net/superman.nsf/ListOfPowersView?ReadViewEntries

Return Results


<?xml version="1.0" encoding="UTF-8"?>
<!-- Lotus-Domino (Release 7.0.1 HF229 - June 09, 2006 on Windows NT/Intel) -->
<viewentries toplevelentries="22">
<viewentry position="1" unid="248DA8555A7B76DD852571BE004381F6" noteid="111646" siblings="22">
<entrydata columnnumber="0" name="$1">
<text>The Power of Flight</text>
</entrydata>
</viewentry>
<viewentry position="2" unid="BE431990CDFBCFA5852571BE004331B8" noteid="111642" siblings="22">
<entrydata columnnumber="0" name="$1">
<text>X-Ray Vision</text>
</entrydata>
</viewentry>
<viewentry position="3" unid="BD5D4670EA8B1984852571BE004308D4" noteid="111636" siblings="22">
<entrydata columnnumber="0" name="$1">
<text>Invulnerability</text>
</entrydata>
</viewentry>
</viewentries>


Syntax and Examples


http://Host/Database/ViewName?ReadViewEntries

http://www.lotus.com/ldd/nd6forum.nsf/Search?ReadViewEntries



http://Host/Database/ViewUniversalID?ReadViewEntries

http://www.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0?ReadViewEntries



http://Host/Database/$defaultview?ReadViewEntries

http://www.lotus.com/ldd/nd6forum.nsf/$defaultview?ReadViewEntries

(note: a default view must exist in the database)


Optional arguments for ReadViewEntries


Append optional arguments to refine the URL. Combine any of the following arguments for the desired result except where otherwise noted.


Collapse=n


Where n is the row number to display in collapsed format in a hierarchical view. Do not combine this argument with the ExpandView or CollapseView arguments. This works best on views that do not have the "Collapse all when database is first opened." property selected.

http://www.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&Collapse=3



CollapseView


Displays the view in collapsed format. This works best on views that do not have the "Collapse all when database is first opened." property selected.

http://www.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&CollapseView



Count=n


Where n is the number of rows to display. This is a request and is ultimately controlled by the "Maximum lines per view page" setting on the Domino Web Engine tab in the Server's Document. A value of -1 will request the maximum amount.

http://www-10.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&Count=22



Expand=n


Where n is the row number to display in expanded format in a hierarchical view. Do not combine this argument with the ExpandView or CollapseView arguments.

http://www.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&Expand=3



ExpandView


Displays the view in expanded format.

http://www.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&ExpandView



KeyType=text|time


Specifies the type of StartKey. The default when no argument is specified is text. Setting the KeyType to time allows you to use a time value as the value for StartKey which dictates from what row to display the view and the value for UntilKey, which specifies where to stop display of the view. If &KeyType=time is specified, then &StartKey and &UntilKey may be ISO date time values. For example, you might use the time value 20020101T140000,00Z to represent 9:00AM Eastern standard Time in Coordinated Universal Time (UTC) or Greenwich Mean Time (GMT), or you might use the time value 20020101T090000,00-05 to represent the same date and time in local time plus offset.

http://www.lotus.com/ldd/nd6forum.nsf/Dateallflatweb?ReadViewEntries&StartKey=20060901T162000,00Z&KeyType=time


http://www.lotus.com/ldd/nd6forum.nsf/PlatformAllThreadedweb?ReadViewEntries&StartKey=Linux&KeyType=text



PreFormat


Causes all data types to be converted to text on the server. Text lists, numbers, dates and lists of numbers are converted to text before being sent. The server's locale is used for all formatting. Without this argument, the XML output stream contains information in structured, locale-neutral formats.

http://www.lotus.com/ldd/nd6forum.nsf/CategoryAllThreadedWeb?ReadViewEntries&ExpandView&PreFormat



ResortAscending=column number


Where column number is the 0-based number of the column in the view you wish to resort in ascending or descending alphanumeric order. The column to be sorted must be set up as sortable in the view design. If not no action is taken.

http://www.lotus.com/ldd/nd6forum.nsf/ReleaseAllThreadedWeb?ReadViewEntries&ExpandView&ResortAscending=3



ResortDecending=column number


Where column number is the 0-based number of the column in the view you wish to resort in ascending or descending alphanumeric order. The colue to be sorted must be set up as sortable in the view design. If not no action is taken.

http://www.lotus.com/ldd/nd6forum.nsf/ReleaseAllThreadedWeb?ReadViewEntries&ExpandView&ResortDecending=3



RestrictToCategory=category


Where category is the category to be displayed in the view. Sets the category for the "Show Single Category" object. Results will not include the Category, just its entries.

http://www-10.lotus.com/ldd/nd6forum.nsf/PlatformAllThreadedweb?ReadViewEntries&RestrictToCategory=iSeries



Start=n


Where n is the row number to start with when displaying the view. The row number in a hierarchical view can include subindexes (for example, Start=3.5.1 means the view will start at the third main topic, subtopic 5, document 1).

http://www.lotus.com/ldd/nd6forum.nsf/AuthorAllThreadedweb?ReadViewEntries&Start=11751



StartKey=string


Where string is a key to a document in sorted view. The view displays at that document. In cases where there is no match for the StartKey, the next available entry is used as the starting point.

http://www.lotus.com/ldd/nd6forum.nsf/AuthorAllThreadedweb?ReadViewEntries&StartKey=Mac%20Guidera



UntilKey=string


UntilKey is only valid when used with StartKey. It allows you to display the range of view entries beginning with the document specified by StartKey until the document specified by UntilKey. For example, &StartKey=A&UntilKey=B would give you all the entries that start with A. Use the &Count keyword to further limit the number of entries returned within any given range.

http://www.lotus.com/ldd/nd6forum.nsf/PlatformAllThreadedweb?ReadViewEntries&Startkey=Linux&UntilKey=Windows