Examples: Name property (View - Java)

  1. This agent gets the names of all the views 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);
            System.out.println(view.getName()); }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent toggles the name of a view.
    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 = null;
          view = db.getView("All Documents");
          if (view != null)
            view.setName("All");
          else {
            view = db.getView("All");
            if (view != null)
              view.setName("All Documents");
            else
              System.out.println(
                "No \"All\" or \"All Documents\" view");
          }
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }