Navigator / Page concept too simplistic

Hello,
Navigator / Page concept is right but too simplistic.

Generally every Page has state. This state need to be addressed.

In Vaadin 6 we develop something like this.



public class VoPageState {

 public String property1;

 public Integer property2;

}

public MyPage implements com.vaadin.navigator.View<VoPageState> {

    public void navigateTo(VoPageState state) {

    }

}

and later …

navigator.navigateTo(MyPage.class, new VoPageState(...) );


Hope code is self explanatory.

  • Url fragment is serialized and deserialized to VoPageState.
  • Page state is well defined and typed.


Also we need Navigator for TabSheet - encoding ALL pages (=sheets) and its state into URL fragment.

You can easily use a custom FragmentManager and a subclass of Navigator to handle the encoding and decoding (possibly together with a sub-interface of View). If you use a custom ViewDisplay, your Views do not need to be the UI components but you can also have e.g. a single View class (from the point of view of Vaadin Navigator) that maps URI parameters to state objects in your views implementing your parametrized View interface.

There was discussion about and even a prototype of various other features such as an “internal” state (not encoded in URI, …) but we decided to leave these out of the API.
The rationale is that many such features are still doable by the user with reasonable effort and the API is big and complex enough as it stands.

As for using a TabSheet with the view framework, you can simply write your own ViewDisplay which switches tabs and potentially sets their parameters or state. If you don’t want to explicitly register the views, use a custom ViewProvider that scans the tabs of the TabSheet. These should be very simple to implement. We might add an example of this or maybe even a standard helper class at some point -
creating an enhancement request
might help us remember to do that.

I haved developed a little model-view-presenter framework, that takes care of the navigation (Browsers history, back / forward support), supports subview and gives you a gui components for breadcrumbs.
It is eventbased and holds the state of a view in the event, that is fired to bring the view on screen.
Im currently working to bring support for bookmarks to this framework and l may release these little framework (MvpLite) as a free vaadin addon, if anybody is interessted in.

MvpLite is hosted on
github
and i have written a little demo (some kind of webmail) that should demonstrate the power of this framework. You can find the demo
here
.

I also started to write some wiki pages on github. unfortunately I coudnt find time to complete those.

However, you can browse the code to get another idea of how navigation could be implemented or to find a better solution than my.
12444.jar (26.2 KB)

People would definitely be more likely to find it if you publish it as an add-on.

There are already some MVP add-ons, but I believe with a little different approach and feature set.