【发布时间】:2012-11-09 23:57:22
【问题描述】:
我正在尝试在 GWT 应用程序中实现 Mozilla 的 Persona。这是我为测试它而设置的虚拟应用程序的部分代码:
public class OpenId implements EntryPoint {
private native void callWatch(String email)
/*-{
$wnd.navigator.id.watch({
loggedInUser: email,
onlogin: function(assertion){
$wnd.alert("Calling method");
this.@com.gallup.openid.client.OpenId::processLogin(Ljava/lang/String;)(assertion);
$wnd.alert("Called Java Method");
},
onlogout: function(){alert("Logged Out!");}
});
}-*/;
private void processLogin(String assertion){
Window.alert("Logged in!");
personaStatus.setText("Log In Complete.");
}
}
当我调用callWatch 方法时,只显示“调用方法”警告框。其他任何一个都没有被调用过。因此,由于某种原因,代码似乎在第一个警报下方的 JSNI 调用处停止。但是开发模式没有错误。
我不明白为什么 processLogin 方法没有被调用。
我以为我正确地关注了Google's Documentation。
我确实尝试过写作
this.@com.gallup.openid.client.OpenId::processLogin(Ljava/lang/String;)(assertion);
由于this post,OpenID.@... 和 instance.@...。
我不确定还能尝试什么。
【问题讨论】:
-
看起来断言变量可能存在问题... '$wnd.alert(assertion);'显示一个字符串。如果是这样,您是否尝试过将静态字符串传递给您的 processLogin 函数。