Vaadin TouchKit: Issue with NavigationButton

Hello All,

I am facing an issue with Navigation Button.

The below code works fine and the target view is shown without any issues -

layout.addComponent(new NavigationButton(“Manage Physical Servers”, new ServerList()));

But when I use the below code, I see that the target view is shown for a second and then a blank page is displayed -


NavigationButton nav = new NavigationButton(“Manage Physical Servers”);
nav.setTargetView(new ServerList());


ServerList extends NavigationView.

Could this be a bug? Can anyone let me know if I am doing it right?



You can use the target view if your know that NavigationManager already has your target view as next (or previous) component. Most commonly you have multiple views where you can navigate to and thus it is better to instantiate the new view when user actually clicks the navigation button. This also saves some memory on the server side. If you only have one “next view” or users selects one most of the time then you can do it like this:

myView = new ServerList();
navigationButton = new NavigationButton("Server list", myView);

Normally you have click listener that calls navigateTo function with the relevant new view like this:

navButton = new NavigationButton("Server List", new NavigationButtonClickListener() {
  public void buttonClick(NavigationButtonClickEvent event) {
      getNavigationManager().navigateTo(new ServerList());

With this approach NavigationManager/View combination is intelligent enough to start view transition immediately when users clicks and the go to server to fetch the new view. This way you will get “native alike” experience even though there happens a server visit.

I wrote code examples right into forum, so they are likely to so issues, but you should get the ice.