Reputation: 20633
I would like to know some things about gwtp gatekeeper:
if canReveal()
method returns false
, what happens? In my tests, i've been redirected to the defaultplace, i can change it?
having nested presenters, like:
MenuPresenter
- Only visible for admins.
HomePresenter
- Visible for admins and normal users.
When the logged user is a normal user, i want to only "not display" the menu presenter, is that possible?
thanks
Upvotes: 2
Views: 1556
Reputation: 411
Uhm, I think we should update the documentation.
You can also override revealUnauthorizedPlace, this will make sure you have a disctinc process for error handling and for security.
By default, revealUnauthorizedPlace calls revealsErrorPlace.
Upvotes: 1
Reputation: 788
1 - "if canReveal() method returns false, what happens? In my tests, i've been redirected to the defaultplace, i can change it?"
From the GWTP wiki:
"The presenter handling errors is the one revealed by your custom PlaceManager's revealErrorPlace
method. If you do not override that method, then it's the one revealed by your revealDefaultPlace
method."
This is the default implementation of revealErrorPlace
:
public void revealErrorPlace(String invalidHistoryToken) {
revealDefaultPlace();
}
So you can override it in your custom PlaceManager and add more logic to it to redirect to any place you want.
2 - "When the logged user is a normal user, i want to only "not display" the menu presenter, is that possible?"
You can hide the view in the presenter like this:
@Override
protected void onReset() {
super.onReset();
if (!user.getAdmin) {
getView().asWidget().setVisible(false);
}
}
(for PopupPresenters you must override the onReveal() method)
Upvotes: 3