Maximo 7.6.1.1:
Using Jython, I want to open a URL in a browser (in Windows 10).
I've found a Java example:
import java.awt.Desktop;
import java.net.URI;
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI("http://www.example.com"));
}
And I've attempted to convert it to Jython:
from java.awt import Desktop
from java.net import URI
desktop = Desktop.getDesktop()
uri = URI("http://google.com/#q=wonum1%2Cwonum2%2Cwonum3")
desktop.browse(uri)
While the Jython does compile successfully, it does not open the browser.
How can I open a URL in a browser using Jython?
"You can't." Or, more accurately, "It's probably not worth the effort / risk."
From previous experience, using VB to write CGI (which I do NOT recommend), I would guess that putting the code from your question in an automation script might cause a browser session to get launched on the server, where your script was run. Things may have changed since those VB days, 20+ years ago, but I would still be tempted to check.
@Milton was on the right track, I think, but with Maximo it would actually be a little more complicated. This is because when he said, "You could have [the script] return a response", that response would be returned from the business logic layer on the server side to the UI layer on the server side which would then have to return it to the browser, which you would have had to "big C" customize Maximo to expect that response and know what to do with it.
You could maybe return an error from your script, and have the message include a URL. Or use an Autoscript + Conditional UI + Launch in Context + Nonpersistent Attribute mix to expose a link for the user to click.