3

I am trying to deploy JavaFX 2 app using Java Web start (generated by NetBeans) and I need to pass some args to my app using JavaScript.

First question: Is it even possible? Second question: If it is possible, how can I do it. :-)

My JNLP file is:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="MD.jnlp">
  <information>
    <title>MD</title>
    <offline-allowed/>
  </information>
  <resources>
    <jfx:javafx-runtime version="2.2+" 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="MD.jar" size="675286" download="eager" />
    <jar href="lib/log4j-1.2.17.jar" size="519899" download="eager" />
  </resources>
<security>
  <all-permissions/>
</security>

  <applet-desc  width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback"  name="MD" >
    <param name="requiredFXVersion" value="2.2+"/>
  </applet-desc>
  <jfx:javafx-desc  width="800" height="600" main-class="com.blabla.MD"  name="MD" >
    <fx:param name="jmeno" value="hodnota"/>
  </jfx:javafx-desc>
  <update check="always"/>
</jnlp>

And my web page has this code:

<SCRIPT src="./web-files/dtjava.js"></SCRIPT>
<script>
function launchApplication(jnlpfile) {
    dtjava.launch(            {
            url : 'MD.jnlp',
        },
        {
            javafx : '2.2+'
        },
        {}
    );
    return false;
}
</script>

Thx. :-)

2 Answers 2

3

SOLVED:

function launchApplication(jnlpfile) {
            dtjava.launch({
                url: 'MD.jnlp',
                params: {'name':'value'}
            },
            {
                javafx: '2.2+'
            },
            {}
            );
            return false;
        }

and in JavaFX app, parameters are not in String[] args, but you have to get with method:

getParameters();

This is documented in the JavaFX Deployment Guide documentation for the Java Deployment Tookit (dtjava.js) as well as the JavaFX Application getParameters method JavaDoc.

Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to pass Array as parameter instead of String?
1

First question: Is it even possible?

Yes, in general it is possible. I have done something similar but not directly from JavaScript to JNLP.

Second question: If it is possible, how can I do it. :-)

In my scenario I have done only JNLP part and not JS. But think this way: user logins at web page via one of social networks (JS is involved). JS and Ajax passes required values to server side and redirect user to a page where JNLP applet is deployed.

At server side there is a jnlp file template:

<fx:param name="jmeno" value="{value}"/>

then since server got a value via Ajax it can generate proper jnlp file using PHP or JSP and give it to a user's browser.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.