ShowTable of Contents
IsHonorShowInOpenDatabaseDialog
This button toggles honoring Show in 'Open Application' dialog.
var dbdir:NotesDbDirectory = session.getDbDirectory("Sales/Acme");
var name:string = dbdir.getName();
if (dbdir.isHonorShowInOpenDatabaseDialog()) {
dbdir.setHonorShowInOpenDatabaseDialog(false);
requestScope.status = "Open database dialog not honored for " + name
} else {
dbdir.setHonorShowInOpenDatabaseDialog(true);
requestScope.status = "Open database dialog honored for " + name
}
Name
This computed field displays the name of a database directory set elsewhere on the page.
if (sessionScope.dbdir != null) {
var dbdir:NotesDbDirectory = sessionScope.dbdir;
return "Working on " + dbdir.getName();
} else {
return "Working locally";
}
Parent
This computed field displays the parent user name when a database directory is instantiated elsewhere on the page.
if (sessionScope.dbdir != null) {
var dbdir:NotesDbDirectory = sessionScope.dbdir;
return dbdir.getParent().getUserName();
}
createDatabase
This button creates a new database in the local directory if it does not already exist.
var dbdir:NotesDbDirectory = session.getDbDirectory(null);
var dbname:string = "newdb";
var dbtitle:string = "New database";
try {
dbdir.openDatabase(dbname);
requestScope.status = "Already exists: " + dbname;
return;
} catch(e) {} // proceed if there is an error i.e. the database does not already exist
var db:NotesDatabase = dbdir.createDatabase(dbname);
var view:NotesView = db.createView("main"); // need at least 1 view to initialize database
db.setTitle(dbtitle);
requestScope.status = "Created " + db.getFileName();
getClusterName
This computed field displays the cluster name for a database directory set elsewhere on the page.
if (sessionScope.dbdir != null) {
var dbdir:NotesDbDirectory = sessionScope.dbdir;
var cluster:string = dbdir.getClusterName("Sales/Acme"); // specifies a server
// var cluster:string = dbdir.getClusterName(); // uses the current server
if (cluster.isEmpty()) {
cluster = "No cluster";
}
return "Cluster name: " + cluster;
}
getFirstDatabase
This data binding for a list box displays the names of all the databases in the current directory.
var out = "";
var dir = session.getDbDirectory("");
var db = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
out = out + db.getFileName() + "\n";
db = dir.getNextDatabase();
}
return out
getNextDatabase
This data binding for a list box displays the names of all the databases in the current directory.
var out = "";
var dir = session.getDbDirectory("");
var db = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
out = out + db.getFileName() + "\n";
db = dir.getNextDatabase();
}
return out
openDatabase
This button creates a new database in the local directory if it does not already exist.
var dbdir:NotesDbDirectory = session.getDbDirectory(null);
var dbname:string = "newdb";
var dbtitle:string = "New database";
try {
dbdir.openDatabase(dbname);
requestScope.status = "Already exists: " + dbname;
return;
} catch(e) {} // proceed if there is an error i.e. the database does not already exist
var db:NotesDatabase = dbdir.createDatabase(dbname);
var view:NotesView = db.createView("main"); // need at least 1 view to initialize database
db.setTitle(dbtitle);
requestScope.status = "Created " + db.getFileName();
openDatabaseByReplicaID
This button opens a local database using a replica ID from elsewhere on the page.
var dir:NotesDbDirectory = session.getDbDirectory(null);
var rid:string = sessionScope.rid;
try {
var db:NotesDatabase = dir.openDatabaseByReplicaID(rid);
} catch(e) {
requestScope.status = "Cannot open database with replica ID " + rid;
return;
}
requestScope.status = "Opened database " + db.getFileName();
openDatabaseIfModified
This button opens the local names.nsf if it was modified in the last 3 hours.
var dir:NotesDbDirectory = session.getDbDirectory(null);
var dt:NotesDateTime = session.createDateTime("Today");
dt.adjustHour(-3);
try {
var db:NotesDatabase = dir.openDatabaseIfModified("names", dt);
} catch(e) {
requestScope.status = "Database cannot be opened";
return;
}
if (db != null) {
requestScope.status = "Database opened";
} else {
requestScope.status = "Database not modified in past 3 hours";
}
openMailDatabase
This button collects statistics on the current user's mail database.
try {
var db:NotesDatabase = session.getDbDirectory("NotesUA/Westford/Notes").openMailDatabase();
var dc:NotesDocumentCollection = db.getAllDocuments();
requestScope.status = "Mail database " + db.getTitle() + " is " +
(db.getSize()/1024).toFixed() + "KB long and has " + dc.getCount() + " documents";
} catch(e) {
requestScope.status = "Error opening mail database\n" + e.toString();
}