Navigate to different tabs

Hi,

I’m trying to links tabs with its own view, so I can open a specific tab by navigating to a certain view.

I have been able to display the layout in the TabSheet component by specifying it in the Navigator constructor, Navigator navigator = new Navigator(this, tabSheet).

But I haven’t been able to create a tab automatically when I for example use navigator.addView() and much less display the view I want when I click the tab.

I hope someone can send me in the right direction.

Thanks,
Valorcurse

Hi,

I don’t think it’s possible to use TabSheet with Navigator API out of the box currently. Navigator API is used to govern certain view area of your UI so that different views can be placed inside the view display or component container. TabSheet is component container as well and that’s why you can specify it as constructor parameter for navigator, but it has different API for tab changing. This is, navigator API might not be implemented so that it would be able to call corresponding tab change methods when the “view” changes as Tabs are not Views per se.

Where navigator changes the view within component container based on URI fragment navigation (browser back and forward buttons) the TabSheet works as similar kind of construct where the content of TabSheet is switched according to the selected Tab. Concept of Tab and View are still much different.

Now that you mentioned it, it might be an interesting feature to be supported in Vaadin in out of the box manner. What you could do meanwhile is to investigate if you could produce wanted results with ViewDisplay interface in Navigator API. This interface has methods which get called when view changes due to navigation events. This way you might be able to call corresponding Tabsheet API.

So, to your navigator constructor, input ViewDisplay which is the TabSheet component implementing the interface.

Yes, this should be easy enough with a custom ViewDisplay - either implemented by the TabSheet or as a separate (non-component) class that controls a TabSheet.

DId you guys implement use of a ViewDisplay? Can you share?

Eventually not, it was a school project and we did not have the time.
You can check in the following link how we implemented it:

https://github.com/valorcurse/stadslab-kennisbank/blob/master/grails-app/vaadin/kennisbank/fabtool/MainView.groovy

Thanks, will check it out!