JAVA/CORBA CLASSES
Examples: getChild, getNextSibling, and getParent methods
1. This agent gets view entries in a hierarchy down to three levels using different variables to represent the entries at different levels.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
String getEntryType(ViewEntry entry) {
String t = null;
try {
if (entry.isCategory()) t = "category";
else if (entry.isDocument()) t = "document";
else if (entry.isTotal()) t = "total"; }
catch (Exception e) {
e.printStackTrace(); }
return t; }
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("By Category");
ViewNavigator nav = view.createViewNav();
int n = 0;
String tabs = null;
ViewEntry entry = nav.getFirst();
while (entry != null) {
n++;
System.out.println
("Entry #" + n + " is a " + getEntryType(entry));
ViewEntry entry2 = nav.getChild(entry);
while (entry2 != null) {
n++;
System.out.println
("\tEntry #" + n + " is a " +
getEntryType(entry2));
ViewEntry entry3 = nav.getChild(entry2);
while (entry3 != null) {
n++;
System.out.println
("\t\tEntry #" + n + " is a " +
getEntryType(entry3));
entry3 = nav.getNextSibling(entry3); }
entry2 = nav.getNextSibling(entry2); }
entry = nav.getNextSibling(entry); }
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent gets view entries in a hierarchy down to three levels using one variable to represent the entries at different levels.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
String getEntryType(ViewEntry entry) {
String t = null;
try {
if (entry.isCategory()) t = "category";
else if (entry.isDocument()) t = "document";
else if (entry.isTotal()) t = "total"; }
catch (Exception e) {
e.printStackTrace(); }
return t; }
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("By Category");
ViewNavigator nav = view.createViewNav();
int n = 0;
ViewEntry entry = nav.getFirst();
while (entry != null) {
n++;
System.out.println
("Entry #" + n + " is a " + getEntryType(entry));
entry = nav.getChild();
if (entry != null) {
while (entry != null) {
n++;
System.out.println
("\tEntry #" + n + " is a " +
getEntryType(entry));
entry = nav.getChild();
if (entry != null) {
while (entry != null) {
n++;
System.out.println
("\t\tEntry #" + n + " is a " +
getEntryType(entry));
entry = nav.getNextSibling(); }
entry = nav.getParent(); }
entry = nav.getNextSibling(); }
entry = nav.getParent(); }
entry = nav.getNextSibling(); }
} catch(Exception e) {
e.printStackTrace();
}
}
}
See Also
getChild method
getNextSibling method
getParent method
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary