All my posts were damaged after the java.net site migrated to the new engine. So, I started to move my previous posts to this site. Shortly, I discovered that I couldn't add any unsafe tags to the page: neither the <applet> nor the <script> tag.
First, I discovered how to insert a script. Then, I came across the mentioning of the universal gadget, which seems to be unsupported now. So, I decided to write a custom gadget to publish my JavaFX applets.
I started with the official description of gadgets for Google Sites. These gadgets are based on the OpenSocial gadgets, although they do not support all the features.
The gadget is described with the <ModulePrefs> tag, which enables you to specify the gadget name and its author. Additionally, you can apply localization. For example, I translated both messages to Russian. Note that XML uses the UTF-8 charset, so I recommend you to use the editor that supports this encoding.
<ModulePrefs title="JavaFX 1.3 applet" author="Sergey Malenkov"> <Locale lang="all"> <msg name="ARCHIVE">JAR-file location</msg> <msg name="CLASS">Full name of the main class</msg> </Locale> <Locale lang="ru"> <msg name="ARCHIVE">Местоположение JAR-файла</msg> <msg name="CLASS">Полное имя главного класса</msg> </Locale> </ModulePrefs>
The <UserPref> tag is used to define the gadget parameters, which could be changed when you're installing the gadget on the page. Note that the localized messages are used to display a parameter name.
<UserPref name="ARCHIVE" display_name="__MSG_ARCHIVE__"/> <UserPref name="CODE" display_name="__MSG_CLASS__"/>
The content should be enclosed within the CDATA block to prevent the XML document from damaging.
<Content type="html"> <![CDATA[ ... ]]> </Content>
I performed automatic calculation of the applet size to avoid adding a new parameter for indicating the applet size.
var url = gadgets.util.getUrlParameters()['parent'] + '/'; var view = gadgets.window.getViewportDimensions(); javafx({ width: view.width, height: view.height, archive: '__UP_ARCHIVE__' ? '__UP_ARCHIVE__' : url, code: '__UP_CODE__' ? '__UP_CODE__' : 'Main', codebase: url });
NB! You must declare that the dynamic-height feature is required within the <ModulePrefs> tag. Without this feature the getViewportDimensions method does not work correctly.
<ModulePrefs ...> <Require feature="dynamic-height"/> ... </ModulePrefs>
You can use the following URL to install my gadget to deploy JavaFX applets:
http://sites.google.com/site/malenkov/gadget/javafx.xml
Also, you can use the following URL to install my gadget to deploy Java applets:
http://sites.google.com/site/malenkov/gadget/java.xml
Recently, I was asked to provide support for JavaFX 2.0 applets. As you know, the Deployment Toolkit was changed since JavaFX 1.3. So, it is much easier to create a new gadget than modify the old ones. You can use the following URL to install my gadget for deploying JavaFX 2.0 applets:
http://sites.google.com/site/malenkov/gadget/javafx2.xml
Open "Insert" and choose "More gadgets..."
Select "Add gadget by URL" in the dialog window and enter the URL
Customize the gadget properties, such as width, height, and other