Load View when View is loaded

Hi,
I want navigateTo other view when the views is loaded.

  • If i naviage to view in the method enter(), i navigate when the view is not show.
  • if i implement the interface ViewChangeListener and navigate in the method afterViewChange it´s the same problems.

So you want to navigate from one view “foo” to another view “bar”, when “foo” is loaded. But you still want “foo” to be shown first, then “bar”? Why?

I want navigate to “foo”, this is a view with information of loading, when “foo” is loaded that “bar” load (read data) and when “bar” is loaded navigate to “bar”.

OK, that makes sense. You need to use a background thread. In the enter method of “foo”, start a thread that calls navigateTo(“bar”); You need to synchronize the thread properly, so you need to wrap your call in a Runnable and pass it to your UI. All in all, it should look something like this:

[code]
public void enter(){

    final UI ui= getUI();
    ui.setPollInterval(1000);
    
    new Thread(){

        @Override
        public void run() {

            //synchronize session
            ui.access(new Runnable() {

                @Override
                public void run() {
                    ui.setPollInterval(0);
                    ui.getNavigator().navigateTo("bar");
                }
            });
            
        }
    }.start();
}

[/code]What will happen is that your thread will try to run, but it can’t, until the current request is being processed. That request will load up “foo” normally, and start polling the server each second. Then your thread will run, navigate to “bar”, and turn off the polling. “foo” should be visible until “bar” has loaded.