JSF根据用户权限剪裁网页
当用户登录我的网站时,我想显示一个带有用户菜单的 div,其中包含他的收件箱、通知等。我是否必须将 JAAS 与 JSF 结合使用才能实现此目的?最好的方法是什么?如果您可以为我指出正确的方向或一些教程,或者是否有一些奇特的方法来做到这一点而不是使用渲染属性。提前致谢。
When a user logs into my website I want to display a div with a user menu, that contains his inbox, notifications, etc. Do I have to use JAAS with JSF to accomplish this? What's the best way to do it? If you could point me in the right direction or maybe some tutorial, or if there's some fancy way to do this instead of using the render attribute. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的安全要求并不复杂,那么无需 Jass 即可实现此目的的简单方法是使用会话范围 bean 来获取用户详细信息。
您向用户呈现登录数据的 div 将由该 bean 控制。
您不必使用渲染,具体取决于您希望向用户显示的内容。
例如,
即使用户注销,也可以始终向用户显示消息。
不过,我会考虑使用 render 属性。
希望这会有所帮助
添加一个简单的会话 bean 示例。
您可以向 bean 添加详细信息,但我建议添加所需的最低限度。
通过这个 bean,您将能够监视用户。
来自 java:
来自 jsf 文件,在其属性上使用 render。我添加了 getLoggedIn 方法作为示例。
java类:
面孔配置:
If your security requirements are not complicated, a simple way of doing this without Jass is by using a session scoped bean for the user details.
The div in which you present the logged in\ logged data to the user will be controlled by this bean.
you will not have to use render, depending on what you wish to display to the user.
for example, a message to the user can be displayed always as
even if the user is logged out.
I would however consider using the render attribute.
Hope this helps
Added a simple example of session bean.
you can add details to the bean however I would suggest adding the minimum needed.
from this bean you will be able monitor the user.
from java:
from jsf files, using render on its attributes. i added getLoggedIn method as an example.
java class:
faces config:
您好,
首先您必须对用户进行身份验证并确定用户具有访问应用程序的权限。为此,您可能会在支持 bean 中设置诸如标志之类的变量。这应该映射到特定组件的渲染属性中。
这是我们根据用户权限显示页面的想法。
HI,
First you have to authenticate the user and decide what permissions user has to access the application. For that may be you will have the variables like flag set in the backing beans. That should be mapped into the render attribute of the specific component.
This is the idea way how we show the pages based on the user permission.