This discussion is archived
6 Replies Latest reply: Jan 15, 2012 3:21 AM by 911060 RSS

dynamic parameters for Webstart

911060 Newbie
Currently Being Moderated
Hi,

I want to create a Webstart-Application that dynamically takes parameters. Looking for a solution I found that the only way seems to be to generate jnlp-files (e.g. using servlets). However, here at the Oracle-pages I found this document

[http://docs.oracle.com/javafx/2.0/deployment/deployment_toolkit.htm]

it says

1. Example 5-11 Canonical Link to Launch a Web Start Application

a href="my.jnlp"
onclick="dtjava.launch(new dtjava.App('my.jnlp'));
return false;">Launch me!</a>

2. Example 5-1 Creating a dtjava.App Object

var app = new dtjava.App(
'test.jnlp',
{
id: 'testApp',
width: 100,
height: 100,
params: { 'variable': 'value'}
});

So, I guess it should work.

But it doesn't. Starting the application embedded in the browser works well.

Does anyone know if this is possible at all or if generating the jnlp-file is really the only solution?

Thanks!
  • 1. Re: dynamic parameters for Webstart
    875756 Pro
    Currently Being Moderated
    I haven't looked at this since jfx came along so perhaps they've added something but in classic jnlp this is not really supported (afaik).

    With desktop install the jnlp is copied and cached on the local system so next time it runs it uses that local cache, which means the 'params' are the ones that were generated on first launch.

    This is pretty annoying since hyperlinking to application content is ubiquitous these days for web apps and there's an expectation from users that desktops should do the same.

    Possibly an option is to do it via the embedded mode and just Popup a new stage (if you want it in its own window). I haven't tried that, so not sure what happens if you kill the browser it was launched from.

    A hack I did years ago was to have my servlet (that generates the jnlp) store the URL parameters for the calling ip address and then when the app started it called onto the servlet to get those parameters for it's ip. A horrible cludge but it got me through at the time.
  • 2. Re: dynamic parameters for Webstart
    911060 Newbie
    Currently Being Moderated
    Thank you! Your answer just confirms that there's no simple way to make the Webstart-version work. Since the servlet hack sounds to difficult to me and I just need a full-screen version, I am now trying to start the standalone via php. Just my php does not yet recognize java (exec('java -version') gives no result. So, I have a long night before me :-).
  • 3. Re: dynamic parameters for Webstart
    EJP Guru
    Currently Being Moderated
    perhaps they have added something
    Exactly. They have added the DeployJava Toolkit the OP is using. None of your comments therefore apply.

    @OP: it should work. make sure your JNLP file either contains a valid href attribute or none. Try the JWS forum.
  • 4. Re: dynamic parameters for Webstart
    911060 Newbie
    Currently Being Moderated
    Waaahh. But thank you! So I will start trying again. Would anyone have a look at my code? The jnlp-file is generated by NetBeans Dev:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="PillBox.jnlp">
      <information>
        <title>PillBox</title>
        <vendor>Carola</vendor>
        <description>Sample JavaFX 2.0 application.</description>
        <offline-allowed/>
      </information>
      <resources os="Windows">
        <jfx:javafx-runtime version="2.0+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
      </resources>
      <resources>
        <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="PillBox.jar" size="1965165" download="eager" />
        <jar href="lib/mysql-connector-java-5.1.13-bin.jar" size="753542" download="eager" />
      </resources>
      <applet-desc  width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback"  name="PillBox" />
      <jfx:javafx-desc  width="800" height="600" main-class="pillbox.PillBox"  name="PillBox" >
    
       <fx:param name="p4" value="true"/>
        <fx:param name="p3" value="4"/>
        <fx:param name="p2" value="500"/>
        <fx:param name="p5" value="true"/>
        <fx:param name="p1" value="500"/>
    
      </jfx:javafx-desc>
      <update check="background"/>
    </jnlp>
    in the html file, I have the script
       <!--javascript für webstart-->
       <SCRIPT src="./web-files/dtjava.js"></SCRIPT>
       <script>
         function launchApplication(jnlpfile) {
    
            var app = new dtjava.App(
               'PillBox.jnlp',
               {
                  width: 500,
                  height: 500,
                  params: { 'p1': '100',
                            'p2': '100',
                            'p3': '3',
                            'p4':'true',
                            'p5':'false'}
                }
            );
    
            dtjava.launch(app);
            return false;
        }
       </script>
    
    </head>
    and the call
    <td align="center" valign="middle"><input style="height: 80px; width: 250px" type="button" value="Simulation mit Webstart starten"
    onClick="return launchApplication('PillBox.jnlp');"></td>
    I tried several variations. " instead of ' and deleting '. Deleting the parameter tags in the jnlp-file. I have no idea what to try next.

    Edited by: 908057 on 14.01.2012 17:48
  • 5. Re: dynamic parameters for Webstart
    EJP Guru
    Currently Being Moderated
    Define 'doesn't work'.
  • 6. Re: dynamic parameters for Webstart
    911060 Newbie
    Currently Being Moderated
    The java-application starts with the parameters defined in the jnlp-file, not with the parameters defined in the script.

    If I delete the parameters from the jnlp-file, the java-applications starts with saying that there are no parameters:
    JOptionPane.showMessageDialog(null,
    "getParameters().getRaw().size() : "+getParameters().getRaw().size() , "", JOptionPane.OK_CANCEL_OPTION);

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points