application.showURL() not working ?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

application.showURL() not working ?

Postby ROCLASI » Tue Aug 31, 2010 11:16 am

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
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5385
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: application.showURL() not working ?

Postby lvostinar » Tue Aug 31, 2010 1:12 pm

ROCLASI wrote: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) ?
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1053
Joined: Tue Feb 19, 2008 10:53 am

Re: application.showURL() not working ?

Postby ROCLASI » Tue Aug 31, 2010 1:31 pm

Yep, found something:

Code: Select all
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)
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5385
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: application.showURL() not working ?

Postby lvostinar » Tue Aug 31, 2010 2:04 pm

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.
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1053
Joined: Tue Feb 19, 2008 10:53 am

Re: application.showURL() not working ?

Postby ROCLASI » Tue Aug 31, 2010 2:08 pm

Case #316411 created.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5385
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: application.showURL() not working ?

Postby d.pearce1417196993 » Fri Dec 18, 2020 12:16 pm

Looks Like Big Sur update has re-opened this issue.

ShowURL works fine with a URL, but not one which links to a file!!
d.pearce1417196993
 
Posts: 18
Joined: Fri Nov 28, 2014 7:49 pm

Re: application.showURL() not working ?

Postby Ruben79 » Fri Dec 18, 2020 12:37 pm

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.

Code: Select all
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?
}
Ruben de Jong
Stb Software Development
SAN Partner

Stb Software Development - http://www.stb.nl
User avatar
Ruben79
 
Posts: 93
Joined: Wed Apr 18, 2007 12:43 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 5 guests