Is it me or does application.showURL() not work (anymore?) in the debug client.
When I use it in the debug (smart) client it returns false and I hear a system beep.
I am using Servoy 5.2.1
ROCLASI:
Is it me or does application.showURL() not work (anymore?) in the debug client.
When I use it in the debug (smart) client it returns false and I hear a system beep.
I am using Servoy 5.2.1
Seems to work for me with a simple example. Do you have an error in the log(s) ?
Yep, found something:
2010-08-31 13:25:18,656 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
java.io.IOException: java.lang.ClassNotFoundException: com.apple.mrj.MRJFileUtils
at com.servoy.j2db.util.BrowserLauncher.openURL(BrowserLauncher.java:60)
at com.servoy.j2db.smart.J2DBClient.showURL(J2DBClient.java:3938)
at com.servoy.j2db.scripting.JSApplication.js_showURL(JSApplication.java:1425)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:353)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3666)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3127)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:458)
at com.servoy.j2db.debug.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:382)
at com.servoy.j2db.FormController.executeFunction(FormController.java:3970)
at com.servoy.j2db.FormController.executeFunction(FormController.java:3858)
at com.servoy.j2db.FormController.executeFunction(FormController.java:3780)
at com.servoy.j2db.FormController$ScriptExecuter.executeFunction(FormController.java:3635)
at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:270)
at com.servoy.j2db.ui.BaseEventExecutor.fireActionCommand(BaseEventExecutor.java:217)
at com.servoy.j2db.smart.dataui.AbstractScriptLabel$5.mouseReleased(AbstractScriptLabel.java:1023)
at java.awt.Component.processMouseEvent(Component.java:6348)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6113)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4714)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Ok, this is a Mac issue. But I don’t see a recent change in that area. Maybe it was broken for some time ? Please open a case, seems we have to update the jar.
Case #316411 created.
Looks Like Big Sur update has re-opened this issue.
ShowURL works fine with a URL, but not one which links to a file!!
application.showURL() also does not work anymore on Windows Server 2019.
We have found that application.executeProgram() is a better alternative even for opening URL’s in smartclient. application.showURL() is only usable in NG client when you want to open new tab or redirect.
If you’re using svyUtils there is this method in scopes.svyIO which covers al os’es and will also work with URLs and mailto: links. Or else just copy the code and adjust to your needs.
function openFileWithDefaultViewer(file) {
// TODO: Support opening in the WC: either plugins.file.writeFile, but required to read the content first or showUrl, if file is accessible from the outside (see deprecated globals.svy_utl_open_file())
// TODO: test Linux support: SampleCode suggests using xdg-open here: https://www.servoy.com/forum/viewtopic.php?f=15&t=15237&p=81646&hilit=application+getosname+and+linux#p81653
// TODO param {String} [mimeType] Required for usage in the Web Client. Used by the browser to determine how to open the file
if (!scopes.svySystem.isSwingClient()) {
throw new scopes.svyExceptions.UnsupportedOperationException('Operation only supported in Smart or Runtime Client');
}
var osName = application.getOSName();
/** @type {String} */
var filePath = file;
if (file instanceof plugins.file.JSFile) {
filePath = file.getAbsolutePath();
}
if (/Windows/.test(osName)) {
application.executeProgram('rundll32', ['url.dll,FileProtocolHandler', filePath]);
} else if (/Linux|Freebsd/.test(osName)) {
application.executeProgram('mozilla', [filePath]);
} else if (/Mac/.test(osName)) {
application.executeProgram('open', [filePath]);
}
// What if no match?
}