GWT 平台网守和嵌套演示者
我想了解有关 gwtp gatewaykeeper 的一些信息:
如果
canReveal()
方法返回false
,会发生什么?在我的测试中,我已被重定向到默认位置,我可以更改它吗?有嵌套的演示者,例如:
MenuPresenter
- 仅对管理员可见。HomePresenter
- 对管理员和普通用户可见。当登录用户是普通用户时,我只想“不显示”菜单演示器,这可能吗?
谢谢
I would like to know some things about gwtp gatekeeper:
if
canReveal()
method returnsfalse
, 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1 - “如果 canReveal() 方法返回 false,会发生什么?在我的测试中,我已被重定向到默认位置,我可以更改它吗?”
来自 GWTP wiki:
“演示者处理错误是由您的自定义 PlaceManager 的
revealErrorPlace
方法显示的错误。如果您不重写该方法,那么它就是您的自定义 PlaceManager 的revealErrorPlace
方法显示的错误。revealDefaultPlace
方法。”这是
revealErrorPlace
的默认实现:因此您可以在自定义 PlaceManager 中覆盖它并向其添加更多逻辑以重定向到您想要的任何位置。
2 - “当登录的用户是普通用户时,我只想“不显示”
菜单演示器,这可能吗?”
您可以像这样隐藏演示器中的视图:(
对于 PopupPresenters,您必须重写 onReveal() 方法)
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 yourrevealDefaultPlace
method."This is the default implementation of
revealErrorPlace
: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:
(for PopupPresenters you must override the onReveal() method)
嗯,我认为我们应该更新文档。
您还可以覆盖revealUnauthorizedPlace,这将确保您有一个明确的错误处理和安全流程。
默认情况下,revealUnauthorizedPlace 调用revealErrorPlace。
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.