Question

I have a page that require some object values from another view. when I add the view in the main UI like this :

getNavigator().addView(Home.NAME, Home.class);
getNavigator().addView(Profile.NAME, Profile.class);

It instantiate the Profile view and return NullpointerException because some object are not filled yet. For some internal reasons I don't want to fill the object after that profile has been instantiated. I want to get my object first and then add the view to the navigator when the user browse to the view.

Was it helpful?

Solution

If you look at the vaadin api for Navigator class you can see that you can use an overloaded method addView that does what you want, one of those take an instance of your view instead of a class. Your pofile class must me assignable from View though.

Profile profile = new Profile();
// do more stuff with profile
getNavigator().addView(Profile.NAME, profile);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top