JAVA/CORBA CLASSES


Examples: findNthElement method
This agent displays each paragraph in the Body item of the current or first selected document in reverse order.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();

     // (Your code goes here)
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     Document doc = dc.getFirstDocument();
     RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
     RichTextNavigator rtnav = body.createNavigator();
     if (rtnav.findFirstElement(
     RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
       int count = 0;
       do {
         count++;
       } while (rtnav.findNextElement());
       RichTextRange rtrange = body.createRange();
       for (int i = count; i > 0; i--) {
         if (rtnav.findNthElement(
         RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH, i)) {
           rtrange.setBegin(rtnav);
           System.out.println(i + ") " + rtrange.getTextParagraph());
         }
         else
           System.out.println(i + ") ***Could not find element***");
       }
     }
     else
       System.out.println("No text in Body item");

   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also