次のエージェントは、文書を作成し、文書内のリッチテキストアイテム内に基本的な表を作成した後、表のプロパティを表示して表に入力します。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();
}
}
}