JAVA/CORBA CLASSES


Examples: beginSection method
This agent begins a section at the end of a rich text item. The section contains the contents of a file. The section title is the name of the file.

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();
     if (stream.open(filename)) {
       DocumentCollection dc = agentContext.getUnprocessedDocuments();
       Document doc = dc.getFirstDocument();
       RichTextItem rti = (RichTextItem)doc.getFirstItem("Body");
       RichTextStyle rts = session.createRichTextStyle();
       rts.setBold(RichTextStyle.YES);
       ColorObject color = session.createColorObject();
       color.setNotesColor(RichTextStyle.COLOR_RED);
       rti.beginSection(filename, rts, color, true);
       rti.appendText(stream.readText());
       rti.endSection();
       doc.save(true, true);
     }
     else
       System.out.println("Cannot open " + filename);

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

See Also