Examples: Working with view entries and navigators
- This agent gets all the entries in a view of type category.
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 = db.getView("By Category"); ViewNavigator nav = view.createViewNav(); System.out.println("Categories:"); ViewEntry tmpentry; ViewEntry entry = nav.getFirst(); while (entry != null) { if (entry.isCategory()) System.out.println ("\tPosition " + entry.getPosition('.') + " has " + entry.getDescendantCount() + " descendants"); tmpentry = nav.getNext(); entry.recycle(); entry = tmpentry; } } catch(Exception e) { e.printStackTrace(); } } }
- This agent gets all the entries in a view of type document.
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 = db.getView("By Category"); ViewEntryCollection vec = view.getAllEntries(); System.out.println("Documents:"); ViewEntry tmpentry; ViewEntry entry = vec.getFirstEntry(); while (entry != null) { System.out.println ("\tPosition " + entry.getPosition('.') + "\t" + entry.getDocument().getItemValueString("Subject")); tmpentry = vec.getNextEntry(); entry.recycle; entry = tmpentry; } } catch(Exception e) { e.printStackTrace(); } } }