Deep link questions

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

Deep link questions

Postby jmcneely » Thu Jun 10, 2010 7:14 pm

I'm trying to open a Servoy solution from FileMaker and pass a value to it to set a global variable. I've been told this is possible using a deeplink.

I've got a URL like this:

"172.18.72.xxx:8080/servoy-client/RIS_archive.jnlp?m=start_remote&a=bob|pw|P999990"

The behavior I want is for it to open a servoy window directly with no browser pop-up, and if it is already open, to simply update the IdPatient variable in Servoy with the P999990 string.

Now, if I open this URL from FM it simply opens a browser window and downloads the a file from the servoy app server; I have to manually click it. Furthermore, if the solution is already open, it doesn't update the value, it simply refreshes with the initial value.

I have tried this for the 'start_remote' function in servoy:
================================================
function start_remote(user, password, patient_id)
{
var sa_args = application.getStartupArguments();
var sa_seed = sa_args[0];
var sa = utils.stringReplace(sa_seed,"|"," ");
var sa_user = utils.stringLeftWords(sa,1);
var sa_pw = utils.stringMiddleWords(sa,2,1);
var sa_idpatient = utils.stringRightWords(sa,1);
globals.IdPatient = sa_idpatient;
application.showForm('a0100__Patient__Appt_nav');
}
===============================================

Also, in the servoy-admin web console, I have set servoy.allowExistingClientActivate: to true.

Any help is appreciated!
jmcneely
 
Posts: 45
Joined: Thu May 06, 2010 7:22 pm

Re: Deep link questions

Postby jmcneely » Fri Jun 11, 2010 12:30 am

OK, how about if I narrow the question more simply.

If I have a URL like this to open a smart client:

"172.18.72.241:8080/servoy-client/RIS_archive.jnlp?m=start_remote&a=user|pw|P999990"

and it is set to use an existing client, how do I access the NEW arguments instead of the startup arguments?
jmcneely
 
Posts: 45
Joined: Thu May 06, 2010 7:22 pm

Re: Deep link questions

Postby mboegem » Fri Jun 11, 2010 6:21 am

This behaviour is not supported in smartClient, please review: http://forum.servoy.com/viewtopic.php?f=6&t=8295

If you really need the smartclient for this, there might be a possibility to get a trigger via the solution databroadcast event.
Maybe there's even sort of a 'file listener' which can be set using plain java (don't know if this exists in java)
Anyone else can reply on this?

If you can use the webclient to run you solution however, there's possibilities to reach your goal, please review: http://forum.servoy.com/viewtopic.php?f=9&t=14208
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Deep link questions

Postby pbakker » Fri Jun 11, 2010 9:29 am

This behaviour is not supported in smartClient, please review: viewtopic.php?f=6&t=8295


This is not 100% correct: If Allow Existing Client Activae is true, you can deeplink into existing clients. It will however always open a browser first, as that is the way to handle the url's and trigger something at all. The way Servoy knows which client to activate is based on browser cookies, so the browser is needed for that as well: you cannot talk directly to the running Smart Client, it has to go through the Servoy Application Server.

Also, to make sure you do not get the second sessions, you need to start the first time from a URL that has x=x as parameter: The deeplinking into an existing Smart Client is partly based on cookies. When starting the Smart Client from, for example a desktop shortcut, while deeplink from within an email in a mail client, it can happen that the first deeplink from the mail client opens a new Smart Client anyway. A possible workaround for this is added '?x=x' to the shortcut's URL, like <serverUrl>/servoy-client/mySolutionName.jnlp?x=x

and it is set to use an existing client, how do I access the NEW arguments instead of the startup arguments?

In your example you're calling the method "start_remote". the argument value you supply will be passed to that methods as arguments[0];

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Deep link questions

Postby mboegem » Fri Jun 11, 2010 10:07 am

pbakker wrote:This is not 100% correct: If Allow Existing Client Activae is true, you can deeplink into existing clients.


And what about when the browser doesn't accept cookies?
If this is the case 'Allow Existing Client Activate = true' won't work either.
As this is client side setting you'll never know what the behaviour will be.

I agree, this might be theoretical, but can cause a serious issue if you assume it'll always just work.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Deep link questions

Postby pbakker » Fri Jun 11, 2010 10:11 am

Yeah, then it pretty much stops...
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Deep link questions

Postby mboegem » Fri Jun 11, 2010 10:41 am

Paul,

what about my suggestion to work with databroadcast triggering (could do this via altering a db value in a webclient)/ file listener trigger?

Do you have any experience on this?
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Deep link questions

Postby pbakker » Fri Jun 11, 2010 10:50 am

Technically, that will work. It does mean starting another (web) client session, just to update the database.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Deep link questions

Postby mboegem » Fri Jun 11, 2010 10:56 am

pbakker wrote:Technically, that will work. It does mean starting another (web) client session, just to update the database.


and file listener? Any java code in your cookbook? :wink:
This could avoid the extra session (which could be very short anyway, or even use the webservice plugin to alter the data)
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Deep link questions

Postby pbakker » Fri Jun 11, 2010 11:26 am

If you're into Java coding, then the best option I see if to create a server plugin that exposes a service that allows you to trigger a notifyDataChange to tell the server that data was edited. notifyDataChange is part of the public Java API (IServerAccess).

So, the "other" app inserts a record in a table, you make it call the service to tell the server an insert happened from outside Servoy and then in the Clients you listen to incoming databroadcasts: make sure you touch the table in that client, because the client will only receive databroadcasts for the tables that it's using!

How to expose it as a service can be seen from the different plugins that already so so (for example the RESTful WS plugin).

I would create it in such a way that not everyone can just start calling that service to prevent a DoS attack.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Deep link questions

Postby jmcneely » Tue Jun 15, 2010 12:03 am

pbakker wrote:
This behaviour is not supported in smartClient, please review: viewtopic.php?f=6&t=8295


This is not 100% correct: If Allow Existing Client Activae is true, you can deeplink into existing clients. It will however always open a browser first, as that is the way to handle the url's and trigger something at all. The way Servoy knows which client to activate is based on browser cookies, so the browser is needed for that as well: you cannot talk directly to the running Smart Client, it has to go through the Servoy Application Server.

Paul


OK, I am happy with this up to the point that it runs the method in the existing client, passes the parameters, etc., but it leaves the browser as the frontmost app, obscuring the servoy smart client window. How can I make the smart client end as the frontmost window? I've tried application.updateUI(), no joy.

Thanks for the help so far!
jmcneely
 
Posts: 45
Joined: Thu May 06, 2010 7:22 pm

Re: Deep link questions

Postby pbakker » Tue Jun 15, 2010 10:15 am

Don't think operating systems allows applications to put themselves in front of others: that is up to the user.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Deep link questions

Postby jmcneely » Tue Jun 15, 2010 7:58 pm

pbakker wrote:Don't think operating systems allows applications to put themselves in front of others: that is up to the user.

Paul


Then when they click the button, they end up with a blank browser window showing, with possibly a small hint of a servoy window peeking out from behind it. There simply has to be a better answer than this. I am trying having the script execute an Applescript to force the app to the front, but that is not proving to be so simple either. I'm open to ideas, but I can't just leave it here.

Jim
jmcneely
 
Posts: 45
Joined: Thu May 06, 2010 7:22 pm

Re: Deep link questions

Postby david » Tue Jun 15, 2010 8:55 pm

jmcneely wrote:Then when they click the button, they end up with a blank browser window showing, with possibly a small hint of a servoy window peeking out from behind it. There simply has to be a better answer than this. I am trying having the script execute an Applescript to force the app to the front, but that is not proving to be so simple either. I'm open to ideas, but I can't just leave it here.


Well if you're just worried about Mac clients the following trickery should work if placed at the end of your deeplinked method:

Code: Select all
var PPID = application.executeProgram('/bin/bash','-c', 'echo $PPID')
application.executeProgram('osascript', '-e', 'tell application "System Events"',
   '-e', 'set theprocs to every process whose unix id is ' + PPID,
   '-e', 'repeat with proc in theprocs',
   '-e', 'set the frontmost of proc to true',
   '-e', 'end repeat', '-e', 'end tell')
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Deep link questions

Postby jmcneely » Wed Jun 16, 2010 12:10 am

david wrote:
jmcneely wrote:Then when they click the button, they end up with a blank browser window showing, with possibly a small hint of a servoy window peeking out from behind it. There simply has to be a better answer than this. I am trying having the script execute an Applescript to force the app to the front, but that is not proving to be so simple either. I'm open to ideas, but I can't just leave it here.


Well if you're just worried about Mac clients the following trickery should work if placed at the end of your deeplinked method:

Code: Select all
var PPID = application.executeProgram('/bin/bash','-c', 'echo $PPID')
application.executeProgram('osascript', '-e', 'tell application "System Events"',
   '-e', 'set theprocs to every process whose unix id is ' + PPID,
   '-e', 'repeat with proc in theprocs',
   '-e', 'set the frontmost of proc to true',
   '-e', 'end repeat', '-e', 'end tell')


That worked!!! I owe you a beer or something. Do you drink beer? THANKS!!!!
jmcneely
 
Posts: 45
Joined: Thu May 06, 2010 7:22 pm

Next

Return to Programming with Servoy

Who is online

Users browsing this forum: Bing [Bot] and 10 guests