quinta-feira, 6 de maio de 2010

How to add an applet to your google site

I've had a google site for some time now. I've never really put an effort to do something with it until some weeks ago, when I decided to publish some applet games I've been working on.
First thing first, I clicked on  "More Actions>Manage site>Attachments>Upload" and uploaded my jar.
Well, I always used the <applet> tag to add applets to my sites (ok, I know it is deprecated but still...), so I clicked on the HTML button to add this:
width="300" height="100"
Applet Didn't Load
Just to find that Google sites erases the applet tag!

I knew that the applet tag was deprecated, and I've already saw a google site with an applet, so I knew it was possible to do it. And, after trying a lot of things I found on the Internet, the tag that worked was this little guy:

<!--[if !IE]> Firefox and others will use outer object -->
<object classid="java:main.MainGameApplet.class"
height="505" width="500" >
<!-- Konqueror browser needs the following param -->
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
height="505" width="500" >
<param name="code" value="main.MainGameApplet" />
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
This browser does not have a Java Plug-in.
<br />
<a href="http://java.sun.com/products/plugin/downloads/index.html">
Get the latest Java Plug-in here.
<!--[if !IE]> close outer object -->
And after that google sites wrapped my applet in a beautifull gadget box.