我試圖在GWT應用中實現Mozilla的Persona。下面是一個虛擬的程序,我設置爲測試它的部分代碼:GWT JSNI方法調用失敗,但沒有錯誤
public class OpenId implements EntryPoint {
private native void callWatch(String email)
/*-{
$wnd.navigator.id.watch({
loggedInUser: email,
onlogin: function(assertion){
$wnd.alert("Calling method");
[email protected]::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。
我也嘗試寫
[email protected]::processLogin(Ljava/lang/String;)(assertion);
爲[email protected]
和[email protected]
由於this post。
我不知道還有什麼可以嘗試的。
看起來有可能是這樣的斷言varible一個porblem ...沒有 '$ wnd.alert(斷言);'顯示一個字符串。如果是這樣你嘗試傳遞一個靜態字符串到你的processLogin函數。 – Stefan