Version 1

    Our app needs some app registry and user data, which is loaded asynchronously from the server, after the app is started, to work properly.

    This becomes a problem when a user wants to navigate directly to a page within the app before the server resources are loaded.

    The old solution was to halt the page showing with NavigationControl, but that fell thru when the @Injected dependencies wore expecting the user data to be present on @PostConstruct.

     

    We didn't want to create our EntryPoint because we didn't want to delay Errai's bootstrap.

     

    So the new approach was to create an additional "loading" page where for the user would wait for the resources to be loaded and then be redirected to the desired page.

     

    Our @EntryPoint postConstruct method looks something like this

     

    @PostConstruct
    public void init() {
      
      String currentPage = History.getToken();
      rpc.doLogin(new AsyncCallback<User>() {
        
        @Override
        public void onSuccess(User user) {
          globa.loginState = true;
          
          // rederect user to the last page
          History.newItem(currentPage);
        }
      });
      
      initGUI();
      
      History.newItem(LoadingPage.LOADING_PAGE_PATH);
    }
    

     

    The loading page has an additional check, to redirect a user to a default page so that he doesn't get stuck on a loading animation. This should not happen in a normal flow, but it can (back button, manual url entry...).

    @Templated
    @Page(path = LoadingPage.LOADING_PAGE_PATH)
    public class LoadingPage implements IsElement {
    public static final String LOADING_PAGE_PATH = "loading";
      public void onShow(){
        if(global.loginState != null){
          //redirect to default page
        }
      }
    }
    

     

    I hope this solution will be of some help to anybody with similar problems.