Examples: ViewColumn class

  1. This agent prints the title (or "No title") and position of each column in the "By Category" view of 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();
          View view = db.getView("By Category");
          System.out.println("By Category view");
          Vector columns = view.getColumns();
          if (columns.size() != 0) {
            for (int i=0; i<columns.size(); i++) {
              ViewColumn column = 
               (ViewColumn)columns.elementAt(i);
              String vtitle = column.getTitle();
              if (vtitle.equals("")) vtitle = "No title";
              System.out.println("\t" +
              column.getPosition() + "  " + vtitle); } }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent prints the title (or "No title") and position of the first sorted column in the "By Category" view of 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();
          View view = db.getView("By Category");
          System.out.println("By Category view");
          Vector columns = view.getColumns();
          ViewColumn column = null;
          boolean gotIt = false;
          if (columns.size() != 0) {
            for (int i=0; i<columns.size(); i++) {
              column = (ViewColumn)columns.elementAt(i);
              if (column.isSorted()) {
                gotIt = true; break; } }
            if (gotIt) {
              String vtitle = column.getTitle();
              if (vtitle.equals("")) vtitle = "No title";
              System.out.println("First sorted column is \"" +
              vtitle + "\" in position " +
              column.getPosition()); } 
            else
              System.out.println("No sorted columns"); }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }