Examples: Readers property (Form - Java)

This agent prints the contents of $Readers for the form specified as the agent comment, then adds the current user's name.

import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Agent agent = agentContext.getCurrentAgent();
      Database db = agentContext.getCurrentDatabase();
      Form form = db.getForm(agent.getComment());
      Vector readers = form.getReaders();
      if (readers.size() != 0) {
        System.out.println
        ("$Readers for " + form.getName());
        for (int j=0; j<readers.size(); j++)
          System.out.println
          ("  " + readers.elementAt(j)); }
      else
        System.out.println
        ("No $Readers for " + form.getName());
      readers.addElement(session.getUserName());
      form.setReaders(readers);
      System.out.println
      (session.getUserName() + " added");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}