Notes client Java UI api’s
Bram Withaar
20 November 2009 15:00:00
In Notes851 there are new Java Notes UI api's. One of the classes is a com.ibm.notes.java.ui.NotesUIWorkspace. A very usefull method in that class is runAgent(NotesAgentData agentData, NotesDocumentDataCallback callback, boolean runOnUIContext)
Runs the agent represented by the agent data.
With some simple java code it's possible to call a NotesAgent from java code in a plugin.
The button "nieuw" calls a lotusscript agent, passes in the NotesAgentData, in Lotusscript that's a notesdocument, retrieved with a Session.documentContext.
There's no need for a NotesSession or a NotesThread.
Step 1 is to create a NotesDatabaseData object which describes the server and database where the agent resides
and a NotesAgentData object, which describes what agent to run.
try {
ndd = new NotesDatabaseData(properties.getProperty("Servername"), properties
.getProperty("Database.Path.crm.relaties"));
nad = new NotesAgentData(ndd,"agSideBarButton");
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The NotesAgentData document has a method addItem(String name, Object value)
The items and values added with this method become fields on the notesDocument that's available from the agent trough the Session.DocumentContext
nad.addItem("mailDocUNID", getDocUnid(nUrl));
nad.addItem("crmDocUNID", crmDoc.key );
NotesUIWorkspace ws = new NotesUIWorkspace();
ws.runAgent(nad, new NotesDocumentDataCallback(), false);
Instantiating the NotesUiWorkspace is easy, no need for a seperate thread or other difficult stuff.
The NotesDocumentDataCallback has a method done() that's triggered when the agent is finished.
- Comments [1]

