Examples: Title property (RichTextSection - Java)

  1. This agent displays the title of each section in a rich text item.
    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_SECTION)) {
            System.out.println(doc.getItemValueString("Subject"));
            do {
              RichTextSection rtsection = (RichTextSection)rtnav.getElement();
              System.out.println("\t" + rtsection.getTitle());
            } while (rtnav.findNextElement()); 
          }
          else
            System.out.println("No sections in Body");
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent sets the title of each section in a rich text item.
    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_SECTION)) {
            int count = 0;
            do {
              count++;
              RichTextSection rtsection = (RichTextSection)rtnav.getElement();
              rtsection.setTitle("Section " + count);
            } while (rtnav.findNextElement()); 
            doc.save(true, true);
          }
          else
            System.out.println("No sections in Body");
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }