Hello, this is my first post and it’s been a couple of days trying to hack something with Vaadin. I come from a Struts / JSF based background and this is my first ‘contact’ with GWT based frameworks and that kind of Java Web development.
One of the most important things in the context of the applications I had worked on is the routing/controlling from one view to another. For example you get the initial login Screen (view) but then you want to move to the main screen which then again might have several menu items that might redirect the user to other screens views. In struts you had Actions pointing to other actions, in JSF you had rules and xml wiring pointing to different Views.
I have been studying a bit, several examples (especially the gasdiary example) and some others and I could see the use of the ViewManager Pattern. Where it ‘caches’ components and switches screens. The ViewManager is wired into the Application object and is being called whenever we want to move from another view to something else.
Question1 : Is it still the recommended way (pattern) or there something better I could have a look (I can see lots of 2009 posts).
Question2 : Are there any more concrete examples with complex routing and navigation - it seems that most of the examples are basic stuff with a couple of windows instantiated or just a single view.
Many thanks for your time, any tip would be highly appreciated!
Sure, the view manager is a quite viable pattern. Nevertheless, it would be great if other Vaadin developers would share their views (pun intended) about the topic if they have other good patterns.
Besides the Gas Diary, Directory has some implementations of the pattern. For example,
AppFoundation has a ViewHandler and I think
TPT also has one. The
Navigator add-on also has a menu and confirmation for switching from one view to another. Well, Directory may have some other similar stuff as well.
Maybe this is a stupid question, but…
Is com.vaadin.navigator.Navigator effectively replacing what Gas Diary’s
ViewManager does? In that case this would be an updated answer to Paris’s first question.
Of course there are lots of ways you could go, but I have very good experiences in using some kind of ViewManager in conjunction with a ControllerManager. This is because in my world of rules the views should be quite “stupid”. They are just replaceable components to visualize some kind of I/O on the screen. The application logic should be placed in some kinds of controllers (yes MVC, here we go). Those controllers also implement the Vaadin view listeners to react after the user did some kind of input or action. The navigational structure of the application could be moulded into those controllers, too - but you may want to extract it to somewhere else - so you distinguish between technical view controllers and non-technical navigational controllers. These controllers build some kind of instance hierarchy tree at runtime - similar to view hierachies. Each navigational controller can start/stop 1-n navigational sub-controllers and/or 1-n technical controllers. These in turn can start some other technical sub-controllers for themselves. Each technical controller is responsible for exactly one Vaadin view. The ControllerManager manages the controllers, the ViewManager manages the views. These two communicate with each other.