Wednesday, December 14, 2016

Re: How to make sure object is set before initWidget()

Hello,

I have done like you said it. But I have another problem now.

As you can see the setUsername() method sets the username, and by using a simple alert I've checked and it's correct.

BUT that method does not get called before the constructor, that means that initWidget() gets called first, and I'm using the username there, and it will be null since the setUsername method does not get called before initWidget().

What can I do here in order to have my username set in the initWidget() method.?

public class UserPanel extends Composite implements UserView {

private MaterialContainer container;

private Presenter presenter;

private String username;

        ...

        public UserPanel() {
container = new MaterialContainer();
container.setFontSize("1em");

Widget mainMenu = createMenu();
initWidget(mainMenu);
}

        ...
        
        @Override
public void setUsername(String username) {
this.username = username;
Window.alert(username);
}

@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment