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.
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?
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 /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];
pbakker:
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.
pbakker:
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?
This could avoid the extra session (which could be very short anyway, or even use the webservice plugin to alter the data)
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.
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.
pbakker:
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.
jmcneely:
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:
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')
jmcneely:
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:
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:
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:
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’)