There is no direct way to pass arbitrary parameters to a view because views should always be possible to represent as a URI. However, the parameter of Navigator.navigateTo(String) can contain a parameters part, by default separated from the view name by a slash (“/”). This parameters string can be accessed via ViewChangeEvent.getParameters(). Its content has no special meaning to the framework; the application can use it however it likes. Typically, one would pass the ID of an object to a view, then let the view fetch the object by the id.
This all has the benefit that the URIs in your application work intuitively - the user can copypaste the location URI or store it as a browser bookmark and whenever the URI is loaded, the view knows to show the relevant content.
Is there a better way? I.e. how to I pass in state from a View to a TabBarView to it’s Views?
Im now thinking to start using an EventBus, which one is best for Vaadin?
That is one way of doing it, yes. Of course, an EventBus is another. For Vaadin I would recommend e.g. the BlackBoard add-on.
In regards to ‘a better way’, that really depends on the rest of your app. The way you have there (passing parameters in the constructor) is probably the most widely used and simplest way of doing things. If it is enough in your case, I’d stay with that.
With the Navigator registered in the UI I can navigate and send parameters. After visiting a couple View’s, I need to show
a final TabBarView. Also showed above, where I pass in my id, after I passed the id along into the different TabBarView
View constructors. Is there a better way to do this? Now it seems I have to destroy all the tabs next time around and then
again pass it in via the constructor…
Again, without seeing how your code is structured I am reluctant to give any definitive answers. You don’t need to re-create the tabs if you can just change the content in them:
addTab(main= new MainTab(id));
//and then later..
main.resetId(newId);
Thomas Mattsson i understand what you are saying is that Google is not very good translator but it is the least that could be done by the echo of that don’t speak english … my problem is that he sent a pdf file by email with a plugin of vaadin and everything is sent perfect … the bad news is that when it revised the email that came to me the data in the file are not … let me see if I can help with this problem