Examples: Locating a view

  1. This example finds a view or folder in the current database, as specified by the user in the agent comment.
    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();
          Agent agent = agentContext.getCurrentAgent();
          View view = db.getView(agent.getComment());
          System.out.println
          ("View name:\t" + view.getName());
          System.out.println
          ("Last modified:\t" + view.getLastModified());
          System.out.println
          ("Created:\t\t" + view.getCreated());
          System.out.println
          ("Universal ID:\t" + view.getUniversalID());
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This example finds the default view in the current database.
    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) 
          Database db = agentContext.getCurrentDatabase();
          Vector views = db.getViews();
          for (int i=0; i<views.size(); i++) {
            View view = (View)views.elementAt(i);
            if (view.isDefaultView()) {
              System.out.println
              ("The default view is \"" +
              view.getName() + "\"");
              break; } }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }