Monday, December 12, 2016

How to make sure object is set before initWidget()


I'm creating a menu, and I basically need my UserInfo object already set (based on the username) before creating the menu and doing the initWidget().
Basically I have the username, and based on this, I query the DB and get everything else based on that username.
But I am using an RPC call for the backend part. How can I make sure that userInfo is set before proceeding to the createMenu() and initWidget() part ?

private static UserInfo userInfo;

public UserPanel() {
    container = new MaterialContainer();


   Widget mainMenu = createMenu();

public void setUserInfo(String username) {
    DBGetUserInfoAsync rpcService = (DBGetUserInfoAsync) GWT.create(DBGetUserInfo.class);
ServiceDefTarget target = (ServiceDefTarget) rpcService;
String moduleRelativeURL = GWT.getModuleBaseURL() + "DBGetUserInfoImpl";

rpcService.getUserInfo(username, new AsyncCallback<UserInfo>() {

        public void onSuccess(UserInfo result) {
UserPanel.userInfo = result;

public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());

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
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment