我想在GWT中使用新的Google+ 登录按钮。我找到了这篇 关于如何从 html 制作小部件的帖子,但我还没有成功。
public class GooglePlusSignIn extends Widget{
private final String googleHtml="<span id=\"signinButton\">"
+"<span"
+"class=\"g-signin\""
+"data-callback=\"signinCallback\""
+"data-clientid=\"clientID\""
+"data-cookiepolicy=\"single_host_origin\""
+"data-requestvisibleactions=\"http://schemas.google.com/AddActivity\""
+"data-scope=\"https://www.googleapis.com/auth/plus.login\">"
+"</span>"
+"</span>";
public GooglePlusSignIn(String params) {
Document document = Document.get();
DivElement divElement = document.createDivElement();
divElement.setInnerHTML(googleHtml);
setElement(divElement); //important, widget needs to know it's root element
}
private static native void doJsMagic(Element element)/*-{ //notifies js about element
}-*/;
private static native void undoJsMagic(Element element)/*-{
//notifies js that it should do some cleanup (if needed)
//since it is unaware of GWT widget lifecycle
}-*/;
@Override
public void onAttach() {
super.onAttach();
doJsMagic(getElement());
}
@Override
public void onDetach() {
super.onDetach();
// undoJsMagic(getElement());
}
}