This has been requested before, but unfortunately is a bit of a trick to pull off. These would have to be passed through the jnlp, but the jnlp points to itself and then java web start re-downloads the JNLP. This makes it tricky to use the normal URL argument style parameter passing. It would be handy though, I’ll see if I can’t find a way to make it happen.
Ok, so as this post discussed in detail, this didn’t used to be possible due to how JWS stored cache files on the hard drive.
Guess what? At some point between then and now, JWS totally re-designed their cache, and this is no longer a problem!
You guys can look forward to being able to pass parameters to clients via the URL in 7.4. It will be in the format you’d expect ([tt]/system/launch/client/myproj.jnlp?param1=value¶m2=value[/tt]). These parameter values will be available from scripting, or more conveniently, if the parameter names match up with client tags on the root level with the same names, they’ll be set to the passed-in values.
I don’t think this is a big security flaw, as it is limited to Client tags, so the Designer of the project really has control over what the parameters are able to do.
For those that are following this thread, if you are launching as an applet, Carl has come up with a workaround until 7.4 releases.
Using the applet launch url, load up that page in a browser and look at the source. Make your own version of it, host it somewhere, and point to that.
Looking at that page you can see the line var parameters = {
add your parameters to that section. eg
javaws.launchparams=param1;param2;
javaws.launchparam.param1=Hello
javaws.launchparam.param2=38
You will be able to access this data in Ignition as system properties. java.lang.System.getProperty("name")
As of 7.4, if you set the properties like so, they’ll be applied to the same-named client tags if applicable.
Request this be a gateway project property that enables/disables this feature that is disabled by default. Projects that use this feature will be designed in a deliberate manner where this step seems reasonable.
[quote=“Robert”]For those that are following this thread, if you are launching as an applet, Carl has come up with a workaround until 7.4 releases.
Using the applet launch url, load up that page in a browser and look at the source. Make your own version of it, host it somewhere, and point to that.
Looking at that page you can see the line var parameters = {
add your parameters to that section. eg
javaws.launchparams=param1;param2;
javaws.launchparam.param1=Hello
javaws.launchparam.param2=38
You will be able to access this data in Ignition as system properties. java.lang.System.getProperty("name")
As of 7.4, if you set the properties like so, they’ll be applied to the same-named client tags if applicable.[/quote]
Greetings all. I work with Robert, and I’ve been trying to get a prototype of the above solution working. I’ve got some additional parameters being injected into the var parameters section and the project seems to be happy with them (at least it loads and runs correctly on the client without objecting to the presence of the new items), but I’m having trouble accessing them from code.
The java.lang.System.getProperty call doesn’t seem to find them. I tried looking at what’s returned by java.lang.System.getProperties (plural) and the additional parameters don’t seem to be part of the set of properties returned, but nor does anything else in the var parameters section. This makes me wonder java.lang.System.getProperty is indeed the right API, or is there a different call I need to use?
I guess you have to access those parameters via Applet.getParameter, not System.getParameter.
You’ll need to grab the instance of Applet that is holding your client. This will be easiest if you have a window open, because you can walk upwards in the Swing hierarchy until you find one.
For example, something like this on a button should work
from javax.swing import JApplet
from javax.swing import SwingUtilities
button = event.source
applet = SwingUtilities.getAncestorOfClass(JApplet, button)
print applet.getParameter("MyParam")