ShowTable of Contents
Aliases
This computed field displays the name and aliases of a view associated with a page data source.
var name:string = view2.getName();
var aliases:string = "";
var iterator:java.util.Iterator = view2.getAliases().iterator();
while (iterator.hasNext()) {
aliases = aliases + (aliases.isEmpty() ? "" : ", ") + iterator.next();
}
return name + (aliases.isEmpty() ? "" : " aka ") + aliases;
This button adds an alias.
var v:NotesView = database.getView("main");
var aliases:java.util.Vector = v.getAliases();
var alias:string = requestScope.query;
if (!alias.isEmpty()) {
aliases.addElement(alias);
v.setAliases(aliases);
}
This button removes an alias.
var v:NotesView = database.getView("main");
var aliases = v.getAliases();
if (aliases.length > 0) {
if (aliases.length == 1) {
v.setAliases(null);
} else {
aliases.removeElement(aliases.lastElement());
v.setAliases(aliases);
}
}
AllEntries
This computed field returns the number of documents in a view that is a data source.
return view1.getAllEntries().getCount().toFixed()
BackgroundColor
This button toggles the background color of a view.
var v:NotesView = database.getView("main");
if (v.getBackgroundColor() == NotesRichTextStyle.COLOR_LIGHT_GRAY) {
v.setBackgroundColor(NotesRichTextStyle.COLOR_YELLOW);
requestScope.status = "New color is yellow";
} else if (v.getBackgroundColor() == NotesRichTextStyle.COLOR_YELLOW) {
v.setBackgroundColor(NotesRichTextStyle.COLOR_WHITE);
requestScope.status = "New color is white";
} else {
v.setBackgroundColor(NotesRichTextStyle.COLOR_LIGHT_GRAY);
requestScope.status = "New color is light gray";
}
ColumnCount
This button gets all column values in a view.
var v:NotesView = database.getView("main");
var names:java.util.Vector = v.getColumnNames();
for (var i = 0; i < v.getEntryCount(); i++) {
// for every row in the view
requestScope.status += "\n";
for (var j = 0; j < v.getColumnCount(); j++) {
// for every column in the row
try {
// get the column value for that row
var values:java.util.Vector = v.getColumnValues(j);
requestScope.status += "\t" + names.elementAt(j) + "=" + values.elementAt(i);
} catch(ee) {
// in case the column value is invalid
requestScope.status += "\t" + names.elementAt(j) + "= unknown";
}
}
}
ColumnNames
This button gets all column values in a view.
var v:NotesView = database.getView("main");
var names:java.util.Vector = v.getColumnNames();
for (var i = 0; i < v.getEntryCount(); i++) {
// for every row in the view
requestScope.status += "\n";
for (var j = 0; j < v.getColumnCount(); j++) {
// for every column in the row
try {
// get the column value for that row
var values:java.util.Vector = v.getColumnValues(j);
requestScope.status += "\t" + names.elementAt(j) + "=" + values.elementAt(i);
} catch(ee) {
// in case the column value is invalid
requestScope.status += "\t" + names.elementAt(j) + "= unknown";
}
}
}
Columns
This button gets the position and title of each column in a view.
var v:NotesView = database.getView("main");
var columns = v.getColumns().iterator();
while (columns.hasNext()) {
var column:NotesViewColumn = columns.next();
requestScope.status += "\n" + column.getPosition().toFixed() + " = " + column.getTitle();
}
Created
This computed field displays the creation and last modification date of a view associated with a page data source.
return view1.getName() + " created on " + view1.getCreated().getLocalTime() +
" and last modified on " + view1.getLastModified()
EntryCount
This button gets all column values in a view.
var v:NotesView = database.getView("main");
var names:java.util.Vector = v.getColumnNames();
for (var i = 0; i < v.getEntryCount(); i++) {
// for every row in the view
requestScope.status += "\n";
for (var j = 0; j < v.getColumnCount(); j++) {
// for every column in the row
try {
// get the column value for that row
var values:java.util.Vector = v.getColumnValues(j);
requestScope.status += "\t" + names.elementAt(j) + "=" + values.elementAt(i);
} catch(ee) {
// in case the column value is invalid
requestScope.status += "\t" + names.elementAt(j) + "= unknown";
}
}
}
HeaderLines
This button gets information on all the views in the current database: whether the view is hierarchical, the number of header lines, and the number of row lines.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v:NotesView = views.next();
requestScope.status += "\n" + v.getName();
var hier:string = v.isHierarchical() ? "Hierarchical" : "Flat";
requestScope.status += "\n\t" + hier + " view";
requestScope.status += "\n\tHeader lines: " + v.getHeaderLines().toFixed();
requestScope.status += "\n\tRow lines: " + v.getRowLines().toFixed();
}
HttpURL
This computed field displays the URL for a view associated with the page. The HTTP URL is displayed if available; otherwise, the Notes URL is displayed.
return view1.getHttpURL() == "" ? view1.getNotesURL() : view1.getHttpURL()
IsCalendar
This button determines whether each view in the current database is standard or calendar, with or without conflict checking.
var views = database.getViews().iterator();
var cal:string = "";
while (views.hasNext()) {
var v:NotesView = views.next();
if (v.isCalendar()) {
cal = "calendar view" + (v.isConflict() ? " with conflict checking" : "");
} else {
cal = "standard outline view";
}
requestScope.status += "\n" + v.getName() + " is a " + cal;
}
IsCategorized
This computed field displays whether a view associated with the page is categorized.
return "This view is " + (view2.isCategorized() ? "" : "not ") + "categorized"
IsConflict
This button determines whether each view in the current database is standard or calendar, with or without conflict checking.
var views = database.getViews().iterator();
var cal:string = "";
while (views.hasNext()) {
var v:NotesView = views.next();
if (v.isCalendar()) {
cal = "calendar view" + (v.isConflict() ? " with conflict checking" : "");
} else {
cal = "standard outline view";
}
requestScope.status += "\n" + v.getName() + " is a " + cal;
}
IsDefaultView
This computed field prints the name of the default view or a message that there is none.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v = views.next();
if (v.isDefaultView()) {
return v.getName() + " is the default view."
}
}
return "There is no default view."
This combo box (complete XML shown) displays the names of all views in the current database, default view first. If the user selects another view from the list, that view is set as the default.
<xp:comboBox id="comboBox1" value="#{requestScope.selectedview}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
var views = database.getViews().iterator();
var viewNames = new Array();
var viewDefaultName = new Array();
while (views.hasNext()) {
var v:NotesView = views.next();
if (v.isDefaultView()) {
viewDefaultName.push(v.getName());
} else {
viewNames.push(v.getName());
}
}
return viewDefaultName.concat(viewNames);
}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
var v:NotesView = database.getView(requestScope.selectedview);
v.setDefaultView(true);
}]]></xp:this.action>
</xp:eventHandler></xp:comboBox>
IsFolder
This button changes the name of a folder.
var nameOld:string = requestScope.query;
if (nameOld.isEmpty()) {
requestScope.status = "No folder name specified";
return;
}
var folder:NotesView = database.getView(nameOld);
if (folder == null) {
requestScope.status = "No folder by that name";
return;
}
if (!folder.isFolder()) {
requestScope.status = "Not a folder";
}
var nameNew:string = requestScope.query2;
if (nameNew.isEmpty()) {
requestScope.status = "No new name specified";
return;
}
folder.setName(nameNew);
requestScope.status = "Folder name changed";
IsHierarchical
This button gets information on all the views in the current database: whether the view is hierarchical, the number of header lines, and the number of row lines.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v:NotesView = views.next();
requestScope.status += "\n" + v.getName();
var hier:string = v.isHierarchical() ? "Hierarchical" : "Flat";
requestScope.status += "\n\t" + hier + " view";
requestScope.status += "\n\tHeader lines: " + v.getHeaderLines().toFixed();
requestScope.status += "\n\tRow lines: " + v.getRowLines().toFixed();
}
IsModified
This computed field displays whether a view associated with the page is modified.
return "This view has " + (view2.isModified() ? "" : "not ") + "been modified"
IsPrivate
This computed field displays whether a view associated with the page is private.
return "This view is " + (view2.isPrivate() ? "private" : "shared")
IsProtectReaders
This button toggles whether a view associated with the page protects $Readers items.
if (view2.isProtectReaders()) {
view2.setProtectReaders(false);
requestScope.status = "View does not protect $Readers";
} else {
view2.setProtectReaders(true);
requestScope.status = "View protects $Readers";
}
IsProhibitDesignRefresh
This button toggles whether a view associated with the page can be refreshed.
if (view2.isProhibitDesignRefresh()) {
view2.setProhibitDesignRefresh(false);
requestScope.status = "View can be refreshed";
} else {
view2.setProhibitDesignRefresh(true);
requestScope.status = "View cannot be refreshed";
}
IsQueryView
This computed field displays whether a view associated with the page is a query view.
return "This view is " + (view2.isQueryView() ? "" : "not ") + "a query view"
LastModified
This computed field displays the creation and last modification date of a view associated with a page data source.
return view1.getName() + " created on " + view1.getCreated().getLocalTime() +
" and last modified on " + view1.getLastModified()
LockHolders
This button locks a view.
database.setDesignLockingEnabled(true);
var v:NotesView = database.getView("main");
try {
if (v.lockProvisional()) {
requestScope.status = v.getName() + " locked";
} else {
requestScope.status = v.getName() + " not locked";
}
} catch(e) {
requestScope.status = v.getName() + " not locked";
}
var lh:java.util.Vector = v.getLockHolders();
requestScope.status += "\n" + (lh.isEmpty() ? "No lock holder" : "\Current lock holder: " + lh.firstElement());
database.setDesignLockingEnabled(false);
Name
This computed field displays the name of the default view.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v = views.next();
if (v.isDefaultView()) {
return v.getName() + " is the default view."
}
}
return "There is no default view."
This button changes the name of a folder.
var nameOld:string = requestScope.query;
if (nameOld.isEmpty()) {
requestScope.status = "No folder name specified";
return;
}
var folder:NotesView = database.getView(nameOld);
if (folder == null) {
requestScope.status = "No folder by that name";
return;
}
if (!folder.isFolder()) {
requestScope.status = "Not a folder";
}
var nameNew:string = requestScope.query2;
if (nameNew.isEmpty()) {
requestScope.status = "No new name specified";
return;
}
folder.setName(nameNew);
requestScope.status = "Folder name changed";
NotesURL
This computed field displays the URL for a view associated with the page. The HTTP URL is displayed if available; otherwise, the Notes URL is displayed.
return view1.getHttpURL() == "" ? view1.getNotesURL() : view1.getHttpURL()
Parent
This computed field displays the name of a view associated with the page and the file name of its parent database.
return view2.getName() + " (" + view2.getParent().getFileName() + ")"
Readers
This button adds a name to
$Readers, or removes all readers.
if (requestScope.query.isEmpty()) {
view1.setReaders(null);
requestScope.status = "$Readers emptied";
return;
};
var readers:java.util.Vector = view1.getReaders();
readers.addElement(requestScope.query);
view1.setReaders(readers);
var newreaders = view1.getReaders().iterator();
requestScope.status = "$Readers:";
while (newreaders.hasNext()) {
requestScope.status += "\n" + newreaders.next();
}
RowLines
This button gets information on all the views in the current database: whether the view is hierarchical, the number of header lines, and the number of row lines.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v:NotesView = views.next();
requestScope.status += "\n" + v.getName();
var hier:string = v.isHierarchical() ? "Hierarchical" : "Flat";
requestScope.status += "\n\t" + hier + " view";
requestScope.status += "\n\tHeader lines: " + v.getHeaderLines().toFixed();
requestScope.status += "\n\tRow lines: " + v.getRowLines().toFixed();
}
SelectionFormula
This button toggles the selection formula for the a view associated with the page.
var sf:string = view1.getSelectionFormula();
if (sf.isEmpty() || sf.endsWith("@All")) {
view1.setSelectionFormula("SELECT @Now < @Adjust(@modified; 0; 0; 6; 0; 0; 0)");
} else {
view1.setSelectionFormula("SELECT @All");
}
Spacing
This button toggles the spacing for a view associated with a page.
switch (view1.getSpacing()) {
case NotesView.SPACING_SINGLE :
view1.setSpacing(NotesView.SPACING_ONE_POINT_25);
requestScope.status = "Spacing set to 1.25";
break;
case NotesView.SPACING_ONE_POINT_25 :
view1.setSpacing(NotesView.SPACING_ONE_POINT_50);
requestScope.status = "Spacing set to 1.5";
break;
case NotesView.SPACING_ONE_POINT_50 :
view1.setSpacing(NotesView.SPACING_ONE_POINT_75);
requestScope.status = "Spacing set to 1.75";
break;
case NotesView.SPACING_ONE_POINT_75 :
view1.setSpacing(NotesView.SPACING_DOUBLE);
requestScope.status = "Spacing set to double";
break;
default:
view1.setSpacing(NotesView.SPACING_SINGLE);
requestScope.status = "Spacing set to single";
}
TopLevelEntryCount
This computed field displays the number of top-level entries in a view associated with the page, allowing for a count exceeding 32767 but not 65535.
var tlec:int = view1.getTopLevelEntryCount();
return (tlec < 0 ? tlec + 65536 : tlec).toFixed();
This computed field displays the number of top-level entries in a view associated with the page, allowing for a count exceeding 65536 and subtracting a total if present.
var nav:NotesViewNavigator = view1.createViewNav();
var entry:NotesViewEntry = nav.getLast();
var tlecs:string = entry.getPosition(".");
tlec = tlecs.indexOf(".") == -1 ? tlecs : tlecs.substring(0, tlecs.indexOf("."));
return entry.isTotal() ? tlec - 1 : tlec;
UniversalID
This computed field resolves the URL for a view and accesses the view. The URL built from the database replica ID and the view universal ID is effectively the same as the URL returned by getURL.
//var theURL = view1.getURL();
var theURL = "notes:///" + database.getReplicaID() + "/" + view1.getUniversalID() + "?OpenView";
var v:NotesView = session.resolve(theURL);
return v.getName()
ViewInheritedName
This button lists the names of all views in the current database plus any inheritance information.
var views = database.getViews().iterator();
while (views.hasNext()) {
var v:NotesView = views.next();
var vin:string = v.getViewInheritedName();
requestScope.status += "\n" + v.getName() + (vin.isEmpty() ? "" : " (inherited from " + vin + ")");
}
clear
This button puts documents in a folder based on a view search, clears the search, and puts documents in another folder based on another search of the same view.
database.updateFTIndex(true);
var v:NotesView = database.getView("main");
var query:string = requestScope.query;
if (!query.isEmpty()) {
if (v.FTSearch(query) > 0) {
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
doc.putInFolder("Search Results", true);
tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
}
}
v.clear();
if (!query2.isEmpty()) {
if (v.FTSearch(query2) > 0) {
doc = v.getFirstDocument();
while (doc != null) {
doc.putInFolder("Search Results 2", true);
tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
}
}
copyColumn
This button creates a new view, deletes its columns, copies a column from another view, and creates two columns.
var v:NotesView = database.getView("main");
// Create "dates" view and remove all columns
var main:NotesView = database.getView("main");
var dates:NotesView = database.createView("dates", "SELECT @All");
while (dates.getColumnCount() > 0) {
dates.removeColumn(dates.getColumnCount());
}
requestScope.status = "New view " + dates.getName();
// Copy column 1 from "main" to "dates"
var col1:NotesViewColumn = dates.copyColumn(main.getColumn(1), 1);
requestScope.status += "\n" + col1.getPosition() + " " + col1.getTitle() + " " + col1.getFormula();
var col2:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Created on", "@Created");
requestScope.status += "\n" + col2.getPosition() + " " + col2.getTitle() + " " + col2.getFormula();
var col3:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Last modified on", "@Modified");
requestScope.status += "\n" + col3.getPosition() + " " + col3.getTitle() + " " + col3.getFormula();
createColumn
This button creates a new view, deletes its columns, copies a column from another view, and creates two columns.
var v:NotesView = database.getView("main");
// Create "dates" view and remove all columns
var main:NotesView = database.getView("main");
var dates:NotesView = database.createView("dates", "SELECT @All");
while (dates.getColumnCount() > 0) {
dates.removeColumn(dates.getColumnCount());
}
requestScope.status = "New view " + dates.getName();
// Copy column 1 from "main" to "dates"
var col1:NotesViewColumn = dates.copyColumn(main.getColumn(1), 1);
requestScope.status += "\n" + col1.getPosition() + " " + col1.getTitle() + " " + col1.getFormula();
var col2:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Created on", "@Created");
requestScope.status += "\n" + col2.getPosition() + " " + col2.getTitle() + " " + col2.getFormula();
var col3:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Last modified on", "@Modified");
requestScope.status += "\n" + col3.getPosition() + " " + col3.getTitle() + " " + col3.getFormula();
createViewEntryCollection
This button adds documents to a new view entry collection.
if (requestScope.query.isEmpty()) {
requestScope.status = "No query";
return;
}
var vec:NotesViewEntryCollection = view3.createViewEntryCollection();
var dc:NotesDocumentCollection = database.FTSearch(requestScope.query);
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
vec.addEntry(doc);
var tmpdoc = dc.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
var entry:NotesViewEntry = vec.getFirstEntry();
while (entry != null) {
requestScope.status += "\n" + entry.getPosition(".") + "\t" + entry.getColumnValues().firstElement();
var tmpentry = vec.getNextEntry(entry);
entry.recycle();
entry = tmpentry;
}
createViewNav
This button gets all the entries in a view.
var v:NotesView = database.getView("main");
var value:string = null;
var nav:NotesViewNavigator = v.createViewNav();
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavFrom
This button gets all the entries in a view starting at the current document.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavFrom(currentDocument.getDocument());
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavFromAllUnread
This button gets all the entries in a view for documents unread by the current user.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavFromAllUnread();
if (nav.getCount() == 0) {
requestScope.status = "No unread documents";
return;
}
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavFromCategory
This button gets all the entries in a view for a specified category.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavFromAllUnread();
if (nav.getCount() == 0) {
requestScope.status = "No unread documents";
return;
}
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavFromChildren
This button gets all the entries in a view for children of the current document.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavFromChildren(currentDocument.getDocument());
if (nav.getCount() == 0) {
requestScope.status = "No children";
return;
}
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavFromDescendants
This button gets all the entries in a view for descendants of the current document.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavFromDescendants(currentDocument.getDocument());
if (nav.getCount() == 0) {
requestScope.status = "No descendants";
return;
}
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
createViewNavMaxLevel
This button gets all the top-level entries in a view.
var v:NotesView = database.getView("main");
var nav:NotesViewNavigator = v.createViewNavMaxLevel(0);
var entry:NotesViewEntry = nav.getFirst();
while (entry != null) {
requestScope.status += "\n" + entry.getColumnValues().elementAt(0);
var tmpentry = nav.getNext();
entry.recycle();
entry = tmpentry;
}
FTSearch
This button puts documents in a folder based on a view search, clears the search, and puts documents in another folder based on another search of the same view.
database.updateFTIndex(true);
var v:NotesView = database.getView("main");
var query:string = requestScope.query;
if (!query.isEmpty()) {
if (v.FTSearch(query) > 0) {
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
doc.putInFolder("Search Results", true);
tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
}
}
v.clear();
if (!query2.isEmpty()) {
if (v.FTSearch(query2) > 0) {
doc = v.getFirstDocument();
while (doc != null) {
doc.putInFolder("Search Results 2", true);
tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
}
}
getAllDocumentsByKey
This button gets all the documents in a view whose first sorted column starts with a specified string.
var v:NotesView = database.getView("main");
var dc:NotesDocumentCollection = v.getAllDocumentsByKey(requestScope.query);
if (dc.getCount() == 0) {
requestScope.status = "No subjects starting with that query";
return;
}
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
}
This button gets all the documents in a view whose first sorted column starts with “Category 1“ and whose second sorted column starts with a specified string.
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var dc:NotesDocumentCollection = v.getAllDocumentsByKey(query);
if (dc.getCount() == 0) {
requestScope.status = "No subjects starting with that query";
return;
}
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
}
getAllEntriesByKey
This button gets all the documents in a view whose first sorted column starts with a specified string.
var v:NotesView = database.getView("main");
var vec:NotesViewEntryCollection = v.getAllEntriesByKey(requestScope.query);
if (vec.getCount() == 0) {
requestScope.status = "No subjects starting with that query";
return;
}
var entry:NotesViewEntry = vec.getFirstEntry();
while (entry != null) {
requestScope.status += "\n" + entry.getDocument().getItemValueString("subject");
var tmpentry = vec.getNextEntry();
entry.recycle();
entry = tmpentry;
}
This button gets all the documents in a view whose first sorted column starts with “Category 1“ and whose second sorted column starts with a specified string.
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var vec:NotesViewEntryCollection = v.getAllEntriesByKey(query);
if (vec.getCount() == 0) {
requestScope.status = "No subjects starting with that query";
return;
}
var entry:NotesViewEntry = vec.getFirstEntry();
while (entry != null) {
requestScope.status += "\n" + entry.getDocument().getItemValueString("subject");
var tmpentry = vec.getNextEntry();
entry.recycle();
entry = tmpentry;
}
getAllReadEntries
This computed field displays the number of unread entries in a view associated with the page.
return view1.getAllUnreadEntries().getCount().toFixed()
getChild
This button gets all the documents in a view arranged hierarchically according the response structure.
function getrd(v1, d1, t1) { // recursive to get all response documents
var tabs:string = t1 + "\t";
var child:NotesDocument = v1.getChild(d1);
while (child != null) {
requestScope.status += "\n" + tabs + child.getItemValueString("subject");
getrd(v1, child, tabs);
tmpchild = v1.getNextSibling(child);
child.recycle();
child = tmpchild;
}
}
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
getrd(v, doc, "");
tmpdoc = v.getNextSibling(doc);
doc.recycle();
doc = tmpdoc;
}
getColumn
This computed field displays the title of the first column of a view associated with the page.
return view1.getColumn(1).getTitle()
getColumnValues
This button gets all column values in a view.
var v:NotesView = database.getView("main");
var names:java.util.Vector = v.getColumnNames();
for (var i = 0; i < v.getEntryCount(); i++) {
// for every row in the view
requestScope.status += "\n";
for (var j = 0; j < v.getColumnCount(); j++) {
// for every column in the row
try {
// get the column value for that row
var values:java.util.Vector = v.getColumnValues(j);
requestScope.status += "\t" + names.elementAt(j) + "=" + values.elementAt(i);
} catch(ee) {
// in case the column value is invalid
requestScope.status += "\t" + names.elementAt(j) + "= unknown";
}
}
}
getDocumentByKey
This button gets the first document in a view whose first sorted column starts with a specified string.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getDocumentByKey(requestScope.query);
if (doc == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = doc.getItemValueString("subject");
This button gets the first document in a view whose first sorted column starts with “Category 1“ and whose second sorted column starts with a specified string.
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var doc:NotesDocument = v.getDocumentByKey(query);
if (doc == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = doc.getItemValueString("subject");
getEntryByKey
This button gets the first document in a view whose first sorted column starts with a specified string.
var v:NotesView = database.getView("main");
var entry:NotesViewEntry = v.getEntryByKey(requestScope.query);
if (entry == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = entry.getDocument().getItemValueString("subject");
This button gets the first document in a view whose first sorted column starts with “Category 1“ and whose second sorted column starts with a specified string.
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var entry:NotesViewEntry = v.getEntryByKey(query);
if (entry == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = entry.getDocument().getItemValueString("subject");
getFirstDocument
This button gets all the documents in a view from first to last.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
getLastDocument
This button gets all the documents in a view from last to first.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getLastDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = v.getPrevDocument(doc);
doc.recycle();
doc = tmpdoc;
}
getNextDocument
This button gets all the documents in a view from first to last.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = v.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
getNextSibling
This button gets all the top-level documents in a view.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
tmpdoc = v.getNextSibling(doc);
doc.recycle();
doc = tmpdoc;
}
getNthDocument
This button gets the document in a view associated with the XPage at a specified top-level position.
var doc:NotesDocument = view1.getNthDocument(requestScope.query * 1);
if (doc != null) {
requestScope.status = doc.getItemValueString("subject");
} else {
requestScope.status = "No document at that position";
}
getParentDocument
This button gets all the top-level documents in a view in reverse order.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getLastDocument();
while (doc.isResponse()) {
doc = v.getParentDocument(doc);
}
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
tmpdoc = v.getPrevSibling(doc);
doc.recycle();
doc = tmpdoc;
}
getPrevDocument
This button gets all the documents in a view from last to first.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getLastDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc = v.getPrevDocument(doc);
doc.recycle();
doc = tmpdoc;
}
getPrevSibling
This button gets all the top-level documents in a view in reverse order.
var v:NotesView = database.getView("main");
var doc:NotesDocument = v.getLastDocument();
while (doc.isResponse()) {
doc = v.getParentDocument(doc);
}
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
tmpdoc = v.getPrevSibling(doc);
doc.recycle();
doc = tmpdoc;
}
getURL
This computed field resolves the URL for a view and accesses the view. The URL returned by getURL is effectively the same as the URL built from the database replica ID and the view universal ID.
var theURL = view1.getURL();
//var theURL = "notes:///" + database.getReplicaID() + "/" + view1.getUniversalID() + "?OpenView";
var v:NotesView = session.resolve(theURL);
return v.getName()
lock
This button locks a view.
database.setDesignLockingEnabled(true);
var v:NotesView = database.getView("main");
try {
if (v.lock(true)) {
requestScope.status = v.getName() + " locked";
} else {
requestScope.status = v.getName() + " not locked";
}
} catch(e) {
requestScope.status = v.getName() + " not locked";
}
var lh:java.util.Vector = v.getLockHolders();
requestScope.status += "\n" + (lh.isEmpty() ? "No lock holder" : "\Current lock holder: " + lh.firstElement());
database.setDesignLockingEnabled(false);
lockProvisional
This button locks a view.
database.setDesignLockingEnabled(true);
var v:NotesView = database.getView("main");
try {
if (v.lockProvisional()) {
requestScope.status = v.getName() + " locked";
} else {
requestScope.status = v.getName() + " not locked";
}
} catch(e) {
requestScope.status = v.getName() + " not locked";
}
var lh:java.util.Vector = v.getLockHolders();
requestScope.status += "\n" + (lh.isEmpty() ? "No lock holder" : "\Current lock holder: " + lh.firstElement());
database.setDesignLockingEnabled(false);
markAllRead
This button filters a view and marks the results as read.
database.updateFTIndex(true);
var v1:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) {
requestScope.status = "No query";
return;
}
var n:int = v1.FTSearch(requestScope.query);
if (n > 0) {
v1.markAllRead();
requestScope.status = "Hits marked as read: " + n.toFixed();
} else {
requestScope.status = "No hits";
}
markAllUnread
This button filters a view and marks the results as read.
database.updateFTIndex(true);
var v1:NotesView = database.getView("main");
if (requestScope.query.isEmpty()) {
requestScope.status = "No query";
return;
}
var n:int = v1.FTSearch(requestScope.query);
if (n > 0) {
v1.markAllUnread();
requestScope.status = "Hits marked as unread: " + n.toFixed();
} else {
requestScope.status = "No hits";
}
refresh
This button counts the documents in a view, adds a document to the database, then counts the documents in the view again. The count shows the increment because it is refreshed after the document is saved.
var v:NotesView = database.getView("main");
requestScope.status = "Entries = " + v.getTopLevelEntryCount();
var doc:NotesDocument = database.createDocument();
doc.appendItemValue("Form", "main");
doc.appendItemValue("subject", "New document");
doc.save();
requestScope.status += "\nAdded new document";
v.refresh();
// Entry count is incremented because the view is refreshed
requestScope.status += "\nEntries = " + v.getTopLevelEntryCount();
remove
This button removes a view from the current database.
var v:NotesView = database.getView("dates");
if (v != null) {
requestScope.status = "Removing view " + v.getName();
v.remove();
}
removeColumn
This button creates a new view, deletes its columns, copies a column from another view, and creates two columns.
var v:NotesView = database.getView("main");
// Create "dates" view and remove all columns
var main:NotesView = database.getView("main");
var dates:NotesView = database.createView("dates", "SELECT @All");
while (dates.getColumnCount() > 0) {
dates.removeColumn(dates.getColumnCount());
}
requestScope.status = "New view " + dates.getName();
// Copy column 1 from "main" to "dates"
var col1:NotesViewColumn = dates.copyColumn(main.getColumn(1), 1);
requestScope.status += "\n" + col1.getPosition() + " " + col1.getTitle() + " " + col1.getFormula();
var col2:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Created on", "@Created");
requestScope.status += "\n" + col2.getPosition() + " " + col2.getTitle() + " " + col2.getFormula();
var col3:NotesViewColumn = dates.createColumn(
dates.getColumnCount() + 1, "Last modified on", "@Modified");
requestScope.status += "\n" + col3.getPosition() + " " + col3.getTitle() + " " + col3.getFormula();
resortView
This table (complete XML shown) contains two buttons for resorting a view associated with the page.
<xp:table>
<xp:tr>
<xp:td>
<xp:label value="Ascending" id="label1"></xp:label></xp:td>
<xp:td>
<xp:button id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
try {
view3.resortView("subject", true);
} catch(e) {
requestScope.status = "Column not resortable";
}
}]]></xp:this.action>
</xp:eventHandler></xp:button></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Descending" id="label2"></xp:label></xp:td>
<xp:td>
<xp:button id="button3">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
try {
view3.resortView("subject", false);
} catch(e) {
requestScope.status = "Column not resortable";
}
}]]></xp:this.action>
</xp:eventHandler></xp:button></xp:td>
</xp:tr>
</xp:table>
setAliases
This button adds one or more aliases. The user query is expected to use the vertical bar to indicate multiple aliases.
var v:NotesView = database.getView("main");
var aliases:string = requestScope.query;
if (aliases.isEmpty()) {
v.setAliases(null);
requestScope.status = "No alias";
} else {
v.setAliases(aliases);
requestScope.status = aliases.indexOf("|") < 0 ? "One alias" : "Multiple aliases";
}
unlock
This button unlocks a view.
database.setDesignLockingEnabled(true);
var v:NotesView = database.getView("main");
try {
v.unlock();
requestScope.status = v.getName() + " unlocked";
} catch(e) {
requestScope.status = v.getName() + " not unlocked";
}
database.setDesignLockingEnabled(false);