I am very new to Java and have probably misunderstood something. Basically I am just trying to add a function that formats a RichText item ( xml in this case but could be anything ). When I try to save the agent it keeps giving me an error on the line rtXML.appendText(); command. The error is 'unreported exception … ; must be caught or declaredto be thrown. The thing that confuses me the most is why the easyDateFormat process works great but the renderXML process doesn’t seem to work no matter how I try to declare and pass/declare the variables. Some help would be fantastic.
Thx much ~R
import lotus.domino.*;
import java.text.*;
import java.util.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Document cgiDoc = agentContext.getDocumentContext();
// Some stuff happens here
// Call the function
String strDate = easyDateFormat( "yyyyMMdd" );
RichTextItem xmlBody = renderXML( "XMLBody" , cgiDoc );
} catch(Exception e) {
e.printStackTrace();
}
}
// Simple date / time formatter
public String easyDateFormat (String format) {
Date today = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(format);
String datenewformat = formatter.format(today);
return datenewformat;
}
public RichTextItem renderXML (String strName, Document procDoc) {
// Add XML
RichTextItem rtXML = procDoc.createRichTextItem( strName );
rtXML.appendText( "<root><msg>Hello World.</msg></root>" );
return rtXML;
}
}