Navigator Reference in View Component?

Hi all,

I have tried the
tutorial using the navigator and views approach
to controlling page requests for applications. However this does not show how to add a menubar or buttons for navigation. It only uses a Link element to get in-page navigation to work.

In the book of vaadin for vaadin 7 the view examples all use a reference to the Navigator object to handle navigateTo calls in button clicks. It is not clear how this reference gets into the view. Do we have to create a constructor that take the navigator as a reference?

Also if we wanted to have a menubar at the top of all views would we have to create our own view hierarchy with the common functionality? I.E Say we only want the “content” aread to update and the rest of the site to be more or less static?

Thanks

Hello Mark,

You can get a reference to the navigator by using: UI.getCurrent().getNavigator().navigateTo();.

As for the hierarchy it’s fairly easy, you build your GUI like you normally would except you add the navigator to where you want your “content” area. Then you add your views to the navigator which can be hierarchical e.g.: users/view, users/edit, …

I for example use the following as view parameters: users/action:view/id:1 and build a map out of the parameters.

Hope this helps you.

Bart