Examples: IsDefaultView property

  1. This agent 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();
        }
      }
    }
  2. This agent toggles whether a view is the default or not.
    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");
          view.setDefaultView(!view.isDefaultView());
          System.out.println(
            "IsDefaultView = " + view.isDefaultView());
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }