JavaFX - Where is Applet tag?!


For deploying JavaFX in browser, we use JavaScript code as shown below

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer"
        }
    );
</script>

JavaFX uses dtfx.js which in turn uses deployJava.js to detect presence of java, the version of java on the system etc. Refer to Java Deployment Toolkit documentation for more information.

So how does JavaFX deploys as Applet without using Applet tag?

It indeed uses Applet tag, dtfx.js script generates the required Applet tag. It generates two <div> sections. The first section shows the spinning java logo and second sections embeds the Applet. First the spinning logo is shown, when applet is loaded, its visibility status is changed to false.

The generated html tags will be as shown below, which has embedded Applet tag

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<div id="deployJavaApplet1Overlay" 
    style="width:800;height:650;position:absolute;background:white">
    <table width=800 height=650 border=padding=margin=0>
    <tr><td align="center" valign="middle">
        <img src="http://dl.javafx.com/javafx-loading-100x100.gif" width=100 imgHeight=100>
    </td></tr>
    </table>
</div>
<div id="deployJavaApplet1" style="position:relative;left:-10000px">
    <APPLET MAYSCRIPT
        code="org.jdesktop.applet.util.JNLPAppletLauncher"
        archive="JavaFX_Flickr_Image_Viewer.jar,
        http://dl.javafx.com/applet-launcher__V1.1.1.jar,
        http://dl.javafx.com/javafx-rt__V1.1.1.jar,
        http://dl.javafx.com/fxdloader__V1.1.1.jar,
        http://dl.javafx.com/jmc__V1.1.1.jar,
        http://dl.javafx.com/Decora-SSE__V1.1.1.jar,
        http://dl.javafx.com/emptyJarFile-1239792034654__V1.1.1.jar"
        width=800
        height=650>
        <param name="codebase_lookup" value="false">
        <param name="subapplet.classname" value="com.sun.javafx.runtime.adapter.Applet">
        <param name="progressbar" value="false">
        <param name="classloader_cache" value="false">
        <param name="draggable" value="true">
        <param name="MainJavaFXScript" value="carousel.Main">
        <param name="subapplet.displayname" value="JavaFX_Flickr_Image_Viewer">
        <param name="jnlpNumExtensions" value="2">
        <param name="jnlpExtension1" value="http://dl.javafx.com/jmc__V1.1.1.jnlp">
        <param name="jnlpExtension2" value="http://dl.javafx.com/Decora__V1.1.1.jnlp">
        <param name="jnlp_href" value="JavaFX_Flickr_Image_Viewer_browser.jnlp">
        <param name="deployJavaAppletID" value="deployJavaApplet1">
    </APPLET>
</div>

How will we get this generated Applet tag?

Just add displayhtml: true as shown below. This will display the html instead of loading the applet!

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer",
              displayhtml: true
        }
    );
</script>

<script type="text/javascript">var dzone_url = "http://blogs.sun.com/rakeshmenonp/entry/javafx_sudoku_css_support";</script> <script type="text/javascript">var dzone_style = '2';</script> <script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>
<script type="text/javascript"> digg_skin = 'compact'; digg_window = 'new'; </script> <script language="javascript" src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
<script src="http://slashdot.org/slashdot-it.js" type="text/javascript"></script>

Comments:

Good article. I did not know about the displayhtml attribute. Thanks for pointing that out.

I also wrote an article about JavaFX deployment that other readers may find useful:

http://www.dieajax.com/2008/12/19/10-minute-javafx-tutorial-deploy-javafx-applets-and-applications-both-online-and-offline/

Posted by David Miles on April 15, 2009 at 06:17 PM IST #

Thanks David. I liked the article. Yes I think we must stress more on javafxpackager utility. Thanks for sharing it.

Posted by Rakesh Menon on April 16, 2009 at 02:46 AM IST #

<script>
javafx(
{
archive: "JavaFX_Flickr_Image_Viewer.jar",
draggable: true,
width: 800,
height: 650,
code: "carousel.Main",
name: "JavaFX_Flickr_Image_Viewer",
}
);
</script>

The script above will produce an error with IE.

The trailing comma will cause an error.

name: "JavaFX_Flickr_Image_Viewer",

Should be:

name: "JavaFX_Flickr_Image_Viewer"

Posted by Greg on April 16, 2009 at 03:53 AM IST #

Thanks Greg for pointing out. I fixed it. I just removed the line "displayhtml: true" but didn't remove the "," and also didn't try in IE.

Posted by Rakesh Menon on April 16, 2009 at 04:01 AM IST #

hi rakesh i converted another demo from flash to JavaFX please see i start working on my small website on which i will post article and demos just for learning purpose.
i have some questions
In flash there is function loadLibrary(.swf) that will loadd swf at user request this is very useful function suppose there is a contact link button in website and user is not intererted in viewing that so it is ineffecient to load that jar file can we do that kind of stuff in javafx on user request the demo will be loaded and shown in progress bar..

Posted by Farrukh Obaid on April 16, 2009 at 08:44 PM IST #

@Farrukh Your demos look cool! JavaFX does not directly provide loadLibrary like functionality. I tried to get some info from engineers, basically I wanted to explore feasibility of using custom ClassLoaders. But not fully successful yet.

Posted by Rakesh Menon on April 20, 2009 at 04:20 AM IST #

How to provide parameters to run your own JavaFX applet?

Posted by Chunyen Liu on June 02, 2009 at 08:44 PM IST #

@Chunyen Liu you can refer to below post
http://blogs.sun.com/rakeshmenonp/entry/javafx_passing_arguments

Posted by Rakesh Menon on June 11, 2009 at 08:03 AM IST #

i am trying to load the jsp having javafx applet tag into the portal server(WPS 6.1). And on doing so it gives me the Error

exception: JNLP file error: JavaIntegration_browser.jnlp. Please make sure the file exists and check if "codebase" and "href" in the JNLP file are correct..
java.io.FileNotFoundException: JNLP file error: JavaIntegration_browser.jnlp. Please make sure the file exists and check if "codebase" and "href" in the JNLP file are correct.
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.io.FileNotFoundException: JNLP file error: JavaIntegration_browser.jnlp. Please make sure the file exists and check if "codebase" and "href" in the JNLP file are correct.

Do we need a different codebase for its deployement on Portal server.

Posted by Sim on April 11, 2010 at 09:51 AM IST #

@Sim Can you check the value of "codebase" in JNLP files? It must be same as actual URL of the deployed application (accessible via browser)

Posted by Rakesh Menon on April 12, 2010 at 02:45 AM IST #

Post a Comment:
Comments are closed for this entry.
About


The views expressed on this blog are my own and do not necessarily reflect that of my organization

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today