JAVA/CORBA CLASSES


Examples: getParentDocument and getPrevSibling methods
This agent finds the parent of the last document in the By Category view of the current database and counts its direct response documents.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
 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");
     Document doc = view.getLastDocument();
     if (doc.isResponse()) {
       Document parent = view.getParentDocument(doc);
       System.out.print
       ("Last document in \"By Category\" is \"" +
       parent.getItemValueString("Subject") + "\"");
       int count = 1;
       doc = view.getPrevSibling(doc);
       while (doc != null) {
         count++;
         doc = view.getPrevSibling(doc); }
       System.out.println
       (" with " + count + " responses"); }
     else
       System.out.println
       ("Last document in \"By Category\" is \"" +
       doc.getItemValueString("Subject") + "\"");
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also