Retrieving data from a Java agent on XPage load

A very beginner question…I have a form with some fields. When my XPage loads, it should run a Java agent which replaceItemValue the fields in the form with data (all in same database). How do I run the Java agent in XPages to fill my fields with data?

Any hints as keywords to google furthre would help me a lot… Thank you.

Well, I need to clarify my question. I can run a Java agent by in my XPage “Event tab” and “beforePageLoad” add “Simple Actions”:

database.getAgent(“MyJavaAgent”).run();

or

database.getAgent(“MyJavaAgent”).runOnServer();

But the problem is that in the Java agent when I do

AgentContext ac = session.getAgentContext();

doc = ac.getDocumentContext();

System.out.println(doc);

The “doc” is null. What is the right approach here?

Subject: why do I have to enter a subject on a reply

as of 8.5.2 I think you can send in a document object to the agent.

another approach could be to export your java agent to a java file and add that to your webinf folder in project explorer and call that from your xpages.

  • Thomas