ページのナビゲーションのために別のクラスからメソッドを呼び出したい。
そのため、認証用に「UserID」と「Password」を渡します。その後、次のページに移動します。
私のコード:
public class Test2 extends Composite {
HelloUIBinder hb;
AnimationHelper animationHelper;
TestPage tp;
String strEmail, strPass;
private static Test2UiBinder uiBinder = GWT.create(Test2UiBinder.class);
interface Test2UiBinder extends UiBinder<Widget, Test2> {
}
@UiField TextBox txtEmail;
@UiField PasswordTextBox txtPass;
@UiField Button btnLogin;
public Test2() {
initWidget(uiBinder.createAndBindUi(this));
btnLogin.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
strEmail = txtEmail.getText().toString();
strPass = txtPass.getText().toString();
Window.alert(strEmail);
Window.alert(strPass);
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
// TODO Auto-generated method stub
Throwable un = unwrap(e);
Window.alert(un.toString());
}
});
hb.onLogin(strEmail, strPass);
}
});
}
public Throwable unwrap(Throwable e)
{
if(e instanceof UmbrellaException)
{
UmbrellaException ue = (UmbrellaException) e;
if(ue.getCauses().size() == 1)
{
return unwrap(ue.getCauses().iterator().next());
}
}
return e;
}
}
このコードでは、2つのパラメーターを渡してHelloUIBinderクラスのonLogin()メソッドを呼び出します。
onLoginのコード:
public void onLogin(String email, String pass)
{
Window.alert(email);
Window.alert(pass);
if(email == "abc@yahoo.com" && pass == "abc123")
{
RootPanel.get().clear();
tp = new TestPage();
RootPanel.get().add(tp);
animationHelper.goTo(tp, Animation.SLIDE);
}
else
{
Window.alert("Authentication Failed");
}
}
しかし、アプリケーションの実行中にエラーメッセージが表示されます:
"com.google.gwt.core.client.JavaScriptException: (TypeError): 'null' is not an object"
では、このエラーに関する問題は何ですか?
できるだけ早く解決策を教えてください。
前もって感謝します。