开发者

Can I embed a Java applet in a Google Wave gadget?

If so, can someone point me in the direction of an example? Or even some code?!

I'm guessing that I can't as the applet embedded in a gadget using the following...

var div = document.getElementById('content_div');

div.innerHTML = 
    "<app开发者_如何学Clet CODE='http://www.echoecho.com/lake.class' width='370' height='200'>
        <param name='image' value='http://www.echoecho.com/sunset.gif' />
     </applet>"

... doesn't work. Maybe I'm over-simplifying the gadget code?

** UPDATE... My next attempt was the following, and still no luck...

    ...
    <script src="http://java.com/js/deployJava.js"></script>
    <script>
    ...

      // end of code copied from Google's basic counter gadget...

      gadgets.util.registerOnLoadHandler(init);

      var attributes = {
        code:'http://www.....co.uk/wave/applets/DrawingLines.class',
        width:'300', 
        height:'300'} ;

      deployJava.runApplet(attributes);

    </script>

    <input type=button value="Click Me!" id="butCount" onClick="buttonClicked()">
    <input type=button value="Reset" id="butReset" onClick="resetCounter()">
  ]]> 
  </Content>
</Module>

I just get Java error box with the top error: "load: class http://www.....co.uk/wave/applets/DrawingLines.class not found.".


http://jameswilliams.be/blog/entry/158 appears do accomplish this using deployJava.runApplet. This was from October 2009, so I don't know if the API has changed much:

<?xml version="1.0" encoding="UTF-8" ?>
<Module>http://dl.getdropbox.com/u/738191/staging/applet.html
  <ModulePrefs title="Hello Wave">
    <Require feature="wave" /> 
  </ModulePrefs>
  <Content type="html">
    <![CDATA[     
    <script>    

        function increment() {
            var num = wave.getState().get("num", 0);
            num++;
            wave.getState().submitDelta({"num":num});
        }
        function getValue() {
            return wave.getState().get("num", 0);
        } 
</script>
<script src="http://java.com/js/deployJava.js"></script>
<script>
    var attributes = {id: 'TestWave',
                      codebase:'<codebase>',
                      code:'griffon.applet.GriffonApplet',
                      archive:'griffon-rt-0.2-BETA.jar,TestWave.jar,plugin.jar,groovy-all-1.6.4.jar',
                      width:'480', height:'320'} ;
    var parameters = {fontSize:16,
                      java_arguments: "-Djnlp.packEnabled=true",
                      jnlp_href:'<codebase>/applet.jnlp',
                      draggable:'true',
                      image:'griffon.png',
                      boxmessage:'Loading TestWave',
                      boxbgcolor:'#FFFFFF', boxfgcolor:'#000000',
                      codebase_lookup: 'false'} ;
    var version = '1.5.0' ;
    deployJava.runApplet(attributes, parameters, version);
</script>
<!--       <APPLET CODEBASE='<codebase>'
        CODE='griffon.applet.GriffonApplet'
        ARCHIVE='griffon-rt-0.2-BETA.jar,TestWave.jar,plugin.jar,groovy-all-1.6.4.jar'
        WIDTH='240' HEIGHT='320'>
    <PARAM NAME="java_arguments" VALUE="-Djnlp.packEnabled=true">
    <PARAM NAME='jnlp_href' VALUE='<codebase>/applet.jnlp'>
    <PARAM NAME='dragggable' VALUE='true'>
    <PARAM NAME='image' VALUE='griffon.png'>
    <PARAM NAME='boxmessage' VALUE='Loading TestWave'>
    <PARAM NAME='boxbgcolor' VALUE='#FFFFFF'>
    <PARAM NAME='boxfgcolor' VALUE='#000000'>
    <PARAM NAME='codebase_lookup' VALUE='false'>
</APPLET-->


    ]]>
  </Content>
</Module>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜