Hi,
I am writing a Java agent (has to be Java, cannot be any other language, since I am using other Java classes from our project) that will compute a URL, which it should finally launch.
I am fairly new to Java/JavaScript development for Notes, so I am at a loss, here, since the Java API seems to be all backend, i.e. it is not able to launch anything.
I tried to use JavaScript window.open(), writing the script using System.out.println, but that doesn’t seem to work.
My requirements are, that
a) I need an action that computes the URL and launches it in a browser
b) this action must run on both, the Notes client and via Web
c) all code should be as encapsulated as possible, as I need to make it easily distributable.
Any help would be greatly appreciated!
Thanks and regards,
Matt.
Subject: open URL in browser using Java agent
hi,you have to use the PrintWriter ‘AgentOutput’ for printing in the browser.
This is because you are printing with sysouts in the standard-stream an this is in a serverside agent the console.
Example from Help:
import lotus.domino.*;
import java.io.PrintWriter;
public class platform5 extends AgentBase
{
public void NotesMain()
{
try
{
Session s = getSession();
String p = s.getPlatform();
PrintWriter pw = getAgentOutput();
pw.println("Platform = " + p);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Subject: open URL in browser using Java agent
Thanks for the hint. I tried it, but it doesn’t seem to make any difference (i.e. still no browser opens up).
This is what my code looks like:
public void NotesMain() {
PrintWriter pw = null;
...
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
pw = getAgentOutput();
...
pw.println("<script language=\"JavaScript\">");
pw.println("window.open("+searchURL+",_blank);");
pw.println("</script>");
}
catch(NotesException ne) {
pw.println("Notes Error! Reason: "+ne.text);
}
catch( Exception e ) {
pw.println("Error! Reason: "+e.getMessage());
}
}
Anything that I am missing?
And I am still wondering, if that exact same code will work either from the Notes client or from the web (I have this gut feeling, that it may work on the web, only, but as I said, I need it to work in both environments).
Any more ideas?
Thanks, Matt.