Subject: answers
-
Does the code actually do what it’s supposed to when it runs the first time? yes2) Are you seeing any errors (other than out of memory)? no
-
Are all of your .jar files included in the agent? we’ve tried it both ways - in the agent, and on the file system
Here’s the code (without the import stuff):
public class JavaAgent extends AgentBase implements PropertyChangeListener {
private Session session;
private AgentContext agentContext;
private Database db;
private Document doc;
private RichTextItem body;
private String noteID;
private boolean flag
private String encodedText;
public void NotesMain(){
try {
session = getSession();
agentContext = session.getAgentContext();
db = agentContext.getCurrentDatabase();
doc = agentContext.getDocumentContext();
noteID = doc.getNoteID();
doc.recycle();
doc = db.getDocumentByID(noteID);
flag = false;
//setLookAndFeel():
Icon leafIcon = UIManager.getIcon(“Tree.leafIcon”);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.put(“Tree.leafIcon”, leafIcon);
ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
//load object with data from doc, if not new
body = (RichTextItem)doc.getFirstItem(“fieldname”);
String nomText = body.getText();
System.out.println(nomText);
//showFrame():
JFrame frame = new NomFrame();
frame.addPropertyChangeListener(this);
frame.setBounds(5, 5, 1260, 1000);
frame.setVisible(true);
System.out.println(“After frame.”);
while (!flag) {
try { Thread.sleep(5000);} catch (Exception e){
e.printStackTrack();}
}
if (encodedText != null) {
body.remove(); // might have text to be replaced, so remove and recreate it
body = doc.createRichTextItem( “fieldname”);
body.appendText(encodedText);
doc.save();
System.out.println(“Saved.”);
doc.recycle();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public foid propertyChange( PropertyChangeEvent evt) {
try {
encodedText = (String)evt.getNewValue();
flag = true;
} catch(Exception e) {
e.printStackTrace();
}
}
}