I'm trying to get the query string paramaters of an agent triggered from web:
http://myhost/mydb.nsf/myagent?open&reportID=96c6
Using org.openntf.domino API and running a Domino 9 server HF441 and org.openntf.domino.xsp_1.0.0.201309021740
I get this exception:
[0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: org.openntf.domino.exceptions.UndefinedDelegateTypeException [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at org.openntf.domino.utils.Factory.getParentDatabase(Factory.ja va:613) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at org.openntf.domino.impl.Document.(Document.java:109) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at org.openntf.domino.utils.Factory.fromLotus(Factory.java:251) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at org.openntf.domino.impl.AgentContext.getDocumentContext(Agent Context.java:85) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at JavaAgent.NotesMain(JavaAgent.java:25) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at lotus.domino.AgentBase.runNotes(Unknown Source) [0D40:0045-1488] 2013-09-03 12:01:56 HTTP JVM: at lotus.domino.NotesThread.run(Unknown Source)
import java.io.PrintWriter;
import java.util.Hashtable;
import org.openntf.domino.AgentBase;
import org.openntf.domino.AgentContext;
import org.openntf.domino.Database;
import org.openntf.domino.Document;
import org.openntf.domino.Session;
public class JavaAgent extends AgentBase {
boolean debug = false;
PrintWriter pw;
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
pw = getAgentOutput();
Database reportDB = session.getDatabase(session.getServerName(),
"report.nsf");
Document doc = agentContext.getDocumentContext();
String qs = doc.getItemValueString("Query_String");
Hashtable ht = CommonJ.parseQueryString(qs);
String reportID = (String) ht.get("reportID");
Document reportDoc = reportDB.getDocumentByID(reportID);
if (null != reportDoc) {
String filename = reportDoc.getFirstItem("$File")
.getValueString();
pw.println(reportDoc.getHttpURL() + "/$file/" + filename);
} else {
pw.println("<h2>Sorry, report not found!");
}
} catch (Exception e) {
pw.println("<h2>Sorry, report not found!");
pw.println(e);
e.printStackTrace();
}
}
}
I've fixed this in my current branch. If you're up to modifying and building from source yourself, this is the change:
https://github.com/OpenNTF/org.openntf.domino/commit/08d48763c22c6cdbb411d37e792a80c84e56eb34
Specifically, in the "getCurrentDatabase" method of org.openntf.domino.impl.AgentContext, change the final "this" in the "fromLotus" call to "getCurrentDatabase()".
Alternatively, I exported a jar from my dev environment that fixed it in my test (this is basically M3 plus a slight bit of work in the Design tree as well as this fix):
https://dl.dropboxusercontent.com/u/23599916/org.openntf.domino-jesse-20130903.jar
Let me know if you still run into trouble!