在GWT中嵌入google-plus

Mar*_*tin 2 gwt google-plus

我正在尝试将Google-Plus嵌入到我的GWT应用程序中.我希望它嵌入到Horizo​​ntalPanel中.我确实读过+ 1button开发者谷歌.我没有在stackoverflow中找到任何有关此特定问题的帖子.我的问题可能是我不明白如何将js包含到GUI组件中.如果您将Google+代码添加到Panel中,我将不胜感激.

Str*_*lok 5

这是怎么做的:

文档:

 <!-- Place this tag in your head or just before your close body tag -->
 <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
 <!-- Place this tag where you want the +1 button to render -->
 <g:plusone></g:plusone>
Run Code Online (Sandbox Code Playgroud)

在GWT:

private void drawPlusOne() {
    String s = "<g:plusone href=\"http://urltoplusone.com\"></g:plusone>";
    HTML h = new HTML(s);
    somePanel.add(h);

    // You can insert a script tag this way or via your .gwt.xml
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("https://apis.google.com/js/plusone.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);
  }
Run Code Online (Sandbox Code Playgroud)