JAVA/CORBA CLASSES
Examples: RichTextTable class
1. This agent creates a document, creates a basic table in a rich text item in the document, then displays the table properties and populates the table.
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();
// Create document with Body item
Document doc = db.createDocument();
doc.appendItemValue("Form", "MainTopic");
doc.appendItemValue("Subject", "Table 4 x 3");
RichTextItem body = doc.createRichTextItem("Body");
// Create table in body item
int rowCount = 4;
int columnCount = 3;
body.appendTable(rowCount, columnCount);
// Print table properties
RichTextNavigator rtnav = body.createNavigator();
RichTextTable rttable = (RichTextTable)rtnav.getFirstElement(
RichTextItem.RTELEM_TYPE_TABLE);
System.out.println("Table properties:");
System.out.println("\tRows = " + rttable.getRowCount());
System.out.println("\tColumns = " + rttable.getColumnCount());
System.out.println("\tCStyle = " + rttable.getStyle());
System.out.println("\tColor = " + rttable.getColor().getNotesColor());
System.out.println("\tColor = " + rttable.getAlternateColor().getNotesColor());
// Populate table
rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TABLECELL);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
body.beginInsert(rtnav);
body.appendText("Row " + (i + 1) + ", column " + (j + 1));
body.endInsert();
rtnav.findNextElement();
}
}
// Save document
doc.save(true, true);
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent gets the cells in the first table in an item and displays the first text paragraph in each cell.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
RichTextNavigator rtnav = body.createNavigator();
if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TABLE)) {
RichTextRange rtrange = body.createRange();
rtrange.setBegin(rtnav);
rtrange.setEnd(rtnav);
RichTextNavigator rtnav2 = rtrange.getNavigator();
RichTextRange rtrange2 = body.createRange();
rtnav2.findFirstElement(RichTextItem.RTELEM_TYPE_TABLECELL);
do {
rtrange2.setBegin(rtnav2);
System.out.println(rtrange2.getTextParagraph());
} while (rtnav2.findNextElement());
}
else
System.out.println("Body contains no tables");
} catch(Exception e) {
e.printStackTrace();
}
}
}
See Also
RichTextTable class
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary