TabSheet Selection by URL Parameter

Can you provide me an example how to select a specific tab via an URL parameter (e.g: tabIndex=3)?
Furthermore, how can i modify the current URL to update the tabIndex when the tabsheet selection is changed?


So I guess you have a
in place that takes of the URL? If not then I suggest you take that to manage view changes and URL updates. The next question is do you use the Tabsheet itself as a main menu for your app or is the Tabsheet in question part of one view? It changes the answer but I will assume for now that it is inside a view, and not the main navigation of the app.

When the url changes the Navigator will do it’s work. Let’s say the URL changes to localhost:8080/myListView/?tabIndex=3. Navigator will then change the view to the class bound to myListView. This class will implement the View interface. After that, Navigator will call myListView.enter(ViewChangeEvent event), which has to be there due to the View interface. The parameters to the view can be found in that event object, that is tabIndex=3. You can now extract it from that event, and say to the tabsheet to select the tab.

@Override public void enter(ViewChangeEvent event) { Map<String, String> params = event.getParameterMap(); String tabIndexString = params.getOrDefault("tabIndex", null); if(tabIndexString != null){ try { int tabIndex = Integer.parseInt(tabIndexString); tabSheet.setSelectedTab(tabIndex) } catch (NumberFormatException e) { //not a number, can't navigate to tab } } } Code written directly in forum, errors may apply. :wink: