Examples: Responses property (Document - Java)

This agent gets all the main documents in a view, then gets their responses by calling a function recursively.

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("All Documents");
      Document doc = view.getFirstDocument();
      while (doc != null) {
        System.out.println(
              doc.getItemValueString("Subject"));
        DocumentCollection responses = doc.getResponses();
        if (responses.getCount() > 0)
          printResponses(responses, "\t");
        doc = view.getNextSibling(doc);
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  
  public void printResponses(DocumentCollection dc, String tabs) {
    
    try {
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        System.out.println(tabs + 
               doc.getItemValueString("Subject"));
        DocumentCollection dc2 = doc.getResponses();
        if (dc2.getCount() > 0)
          printResponses(dc2, tabs + "\t");
        doc = dc.getNextDocument(doc);
        }
    } catch(Exception e) {
      e.printStackTrace();
    }
    
  }
}