public class DefaultPlaceManager extends PlaceManagerImpl
PlaceManagerImpl
that uses
custom name tokens to reveal default, error and unauthorized places.
Important! If you use this class, don't forget to bind
DefaultPlace
,
ErrorPlace
and
UnauthorizedPlace
to Presenter name tokens in
your Gin module.
Note: The default, error and unauthorized places are revealed without updating the browser's URL (hence
the false value passed in revealPlace
).
This will avoid stepping into an infinite navigation loop if the user navigates back (using the browser's back
button).
Here's an example of infinite navigation loop that we want to avoid:
Constructor and Description |
---|
DefaultPlaceManager(EventBus eventBus,
TokenFormatter tokenFormatter,
String defaultPlaceNameToken,
String errorPlaceNameToken,
String unauthorizedPlaceNameToken) |
Modifier and Type | Method and Description |
---|---|
void |
revealDefaultPlace()
Reveals the default place.
|
void |
revealErrorPlace(String invalidHistoryToken)
Reveals the place to display when a user tries to access an invalid place.
|
void |
revealUnauthorizedPlace(String unauthorizedHistoryToken)
Reveals the place to display when a user has been refused the access to a specific place.
|
buildHistoryToken, buildRelativeHistoryToken, buildRelativeHistoryToken, buildRelativeHistoryToken, doRevealPlace, fireEvent, getCurrentPlaceHierarchy, getCurrentPlaceRequest, getCurrentTitle, getEventBus, getHierarchyDepth, getTitle, hasPendingNavigation, navigateBack, onValueChange, onWindowClosing, revealCurrentPlace, revealPlace, revealPlace, revealPlaceHierarchy, revealRelativePlace, revealRelativePlace, revealRelativePlace, setOnLeaveConfirmation, unlock, updateHistory
@Inject public DefaultPlaceManager(EventBus eventBus, TokenFormatter tokenFormatter, String defaultPlaceNameToken, String errorPlaceNameToken, String unauthorizedPlaceNameToken)
public void revealDefaultPlace()
PlaceManager
PlaceRequest
corresponding to their default presenter and call PlaceManager.revealPlace(PlaceRequest, boolean)
with it. Consider passing false
as the second parameter of revealPlace
,
otherwise a new token will be inserted in the browser's history and hitting the browser's
back button will not take the user out of the application.
Important! Make sure you build a valid PlaceRequest
and that the user has access
to it, otherwise you might create an infinite loop.public void revealErrorPlace(String invalidHistoryToken)
PlaceManager
PlaceRequest
corresponding to the desired presenter and
call PlaceManager.revealPlace(PlaceRequest, boolean)
with it. Consider passing false
as the
second parameter of revealPlace
, otherwise a new token will be inserted in the
browser's history and hitting the browser's back button will take the user back to the
invalid page he initially tried to access.
The default implementation is simply to call PlaceManager.revealDefaultPlace()
.
Important! Make sure you build a valid PlaceRequest
and that the user has access
to it, otherwise you might create an infinite loop.revealErrorPlace
in interface PlaceManager
revealErrorPlace
in class PlaceManagerImpl
invalidHistoryToken
- The history token that was not recognised.public void revealUnauthorizedPlace(String unauthorizedHistoryToken)
PlaceManager
Place.canReveal()
returned false
. Application-specific place managers should
build a PlaceRequest
corresponding to the desired presenter and call
PlaceManager.revealPlace(PlaceRequest, boolean)
with it. Consider passing true
as the
second parameter of revealPlace
if you navigate, say, to a login page and want the user
to be able to navigate back to the unauthorized page after login. If you are displaying a page
that simply mentions the error you may want to pass false
, otherwise a new token will
be inserted in the browser's history and hitting the browser's back button will take
the user
back to the unauthorized page he initially tried to access.
The default implementation is simply to call PlaceManager.revealErrorPlace(String)
.
Important! Make sure you build a valid PlaceRequest
and that the user has access
to it, otherwise you might create an infinite loop.revealUnauthorizedPlace
in interface PlaceManager
revealUnauthorizedPlace
in class PlaceManagerImpl
unauthorizedHistoryToken
- The history token that was not authorized.Copyright © 2010–2014 Arcbees. All rights reserved.