I will try to describe an example that may work in your situation. There are many options, but I would like to focus on the simple (and encourage you to come up with where you can configure this).
1. Definition of URL Tokens
Select some URL markers, such as "#mainmenu" and "#editprefs", that will be added to the URL of the main page. They will be used for browser history, so the back and forward buttons work, etc.
URL processing will be done automatically by default by default. PlaceChangeEvent will be launched by PlaceController.
2. Display markers for placing objects
A Place object is just an object-oriented abstraction of a token - this is useful because more advanced markers can also take parameters that need to be analyzed. You will need a way to map markers to Place Objects. This is the responsibility of PlaceHistoryMapper .
In my example, we simply applied PlaceHistoryMapper manually to match "#mainmenu" with MainMenuPlace and "#editprefs" in EditPreferencesPlace.
[Alternatively, you can also use the @WithTokenizers annotation and implement a (empty) PlaceTokenizer for each type of place. You can then use the @Prefix annotation to specify "mainmenu" and "editprefs" as tokens.]
3. Matching places to activities
The Place object itself does nothing - as explained above, it is basically just an abstract token. The actual code will be run in Activity. Thus, you will need to map the places of action. This is the responsibility of ActivityMapper .
In my example, you implement it to map MainMenuPlace with MainMenuActivity and EditPreferencePlace with EditPreferenceActivity.
4. Activities and speakers
For simplicity, in my example, Activities will also implement Presenter. Thus, MainMenuActivity will implement MainMenuPresenter. This is not necessary at all, but perhaps a good starting point. And here Places + Activities can connect to MVP. These two concepts do not require each other, but they work great together:
- Actions + Places is basically the connection between the history token and activity.
- MVP is mainly related to the connection between the presenter and the presentation.
If you allow the Office (or one of its delegates) to implement the presenter, you connected both.
5. Short description
"#mainMenu" ---(PlaceHistoryMapper)---> MainMenuPlace ---(ActivityMapper)---> MainMenuActivity implements MainMenuPresenter