JAVA/CORBA CLASSES


Examples: endInsert method
This agent prepends a paragraph and appends another paragraph to an item.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

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

     // (Your code goes here)
     // Open file - proceed only if file can be opened
     String filename = "c:\\lotus\\notesv6\\notes.ini";
     Stream stream = session.createStream();
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     Document doc = dc.getFirstDocument();
     RichTextItem rti = (RichTextItem)doc.getFirstItem("Body");
     RichTextNavigator rtnav = rti.createNavigator();
     String firstPara = "First paragraph of text.";
     String lastPara = "Last paragraph of text.";
     if (rtnav.findFirstElement(
     RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
       // If Body has text, put first line and NL before existing text
       rti.beginInsert(rtnav);
       rti.appendText(firstPara);
       rti.addNewLine(1);
       rti.endInsert();
     }
     else
       // If Body does not have text, simply add first line and NL
       rti.appendText(firstPara);
     // Put NL and last line at end of existing text
     rti.addNewLine(1);
     rti.appendText(lastPara);
     doc.save(true, true);
       

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

}

See Also