JAVA/CORBA CLASSES


Examples: setValueCustomData method
This agent sets an item in the current document to the serialized value of an object.

import lotus.domino.*;
import java.io.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();

     // (Your code goes here)
     
     // Create custom data object
     IntIntString iis = new IntIntString();
     iis.setData(8, 9, "String9");

     // Store custom data as item
     Document doc = agentContext.getDocumentContext();
     if (doc.hasItem("IntIntStringItem")) {
       Item item = doc.getFirstItem("IntIntStringItem");
       if (item.getType() == Item.USERDATA) {
         item.setValueCustomData("IntIntStringType", iis);
         doc.save();
       }
       else
         System.out.println("Not user data");
     }
     else
       System.out.println("No item IntIntString in document");

   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

// Define custom data
class IntIntString implements Serializable {
 int int1;
 int int2;
 String string1;
 
 void setData(int i1, int i2, String s1) {
   int1 = i1;
   int2 = i2;
   string1 = s1;
 }
 
 void show() {
   System.out.println("Int1 = " + int1);
   System.out.println("Int2 = " + int2);
   System.out.println("String1 = " + string1);
 }
}

See Also