سؤال

I have created two java class with UIBinder in GWT application. I want to navigate one page to another page with help of common method which is declared in EntryPoint class.

But, I can't access method of EntryPoint class on Button Click Event of UIBinder class.

My Code:

HelloUIBinder hb;
@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);

            hb.onLogin(strEmail, strPass);
        }
    });
}

In HelloUIBinder Class,

Method for Login:

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");
    }
}

But, while this method I'm getting UmbrellaException Error message. If I would write same logic within UIBinder class then it would be working fine condition checking.

Now I want to use method from different class by use of class object.

Does anyone have idea ?

Please help to solve this error for calling method from different class.

Thanks in advance.

هل كانت مفيدة؟

المحلول

You should post your stack trace from the Umbrella exception and possibly your UIBinder Template.

I would really recommend using place change events and history mappers to do activity changes. You should take a look at the videos by Ray Ryan

Google I/O 2009 - Best Practices for Architecting GWT App http://www.youtube.com/watch?v=PDuhR18-EdM

Google I/O 2010 - Architecting GWT apps http://www.youtube.com/watch?v=M5x6E6ze1x8

We have been using the MVP and place history for many of our projects and it works exceptionally well. You can navigate with a a simple or using the placeContorller.goTo(new Place()); method. This also enable bookmarks and back button to work correctly.

The other option is that you can construct a ClientFactory singleton implementation in your entry point and use it to handle simple navigation events. But if your application is going to get more complicated in the furture placeControllers are the way to go.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top