Hi all quick question (hopefully).I’m really new to Lotus but I’ve used Java quite a bit and I was attempting to create a library and import it into notes and use it in a Java agent. I’ve gotten that far and I can compile my agent but when I try and test it in a form by having a button and using the @Command([RunAgent];testAgent) I get an “internal processing error: incorrect number of parameters.” error. I was hoping someone could suggest maybe some reasons why this is happening as I don’t see any documentation on extra parameters for the RunAgent command. My agent is pretty standard as its just a notesmain:
import lotus.domino.*;
import com.beyondcentury.Driver;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Driver mydriver = newDriver();
myDriver.test();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Also is there any documents out there on the lifetime of an agent? I was wondering if I could persist the agent sort of like a Singleton object in Java. Anyone know anything about that?
Thanks!
Subject: run agent question
Try using double quotes as below,
@Command([RunAgent];“testAgent”)
Subject: RE: run agent question
Using quotes just returns a different error when I try to preview the page in notes, it throws “Document has not been saved.” Any ideas? Should I be doing something other than previewing in notes?
Thanks!
Subject: RE: run agent question
Occasionally, I’ve seen the problem that a form did not behave the same when invoked from preview in designer instead of using the Create menu form the client. Never could figure this one out, but Cesar’s suggestion is the much more likely cause.
Also note, that you absolutely have to provide the name of the agent as a string (which means: enclose it in double quotes). If you don’t, Notes searches for a temporary variable or a field on the document named testAgent. Since neither of them exists, the value of testAgent is the empty string and you get the error, that a parameter is missing.
On to your next question: Agents are loaded into memory, run under control of the agent manager task to enforce security and then unloaded from memory again. So, an agent will never act like a servlet and usually it doesn’t make sure that the call to your agent always returns the same object. Technically, it will not work anyway. Logically, you might be able to write your code that simulates it.
Subject: RE: run agent question
Thanks much, that did the trick!