TabLayoutPanel - 根据角色显示选项卡
我正在开发一个 GWT 应用程序,其中导航主要是 TabLayoutPane,其中每个选项卡代表不同的功能。我需要的是仅显示允许用户查看的选项卡(每个用户都有一个类似用户或管理员的角色)。
问题是我不知道如何实现这一点,尤其是使用 UIBinder。
这就是我的想法:
- 不要使用 UIBinder 并以编程方式构建 TabLayoutPanel。
- 使用 UIBinder 并根据每个用户角色隐藏某些选项卡(这听起来效率很低)。
或者有更好的方法来实现这样的目标吗?
I'm developing a GWT-Application where the navigation is mainly a TabLayoutPane, where each Tab represents a different functionality. What I need is to only show tabs the user is allowed to see (each user has a role like user or admin).
The problem is I don't know how to achieve this, especially with UIBinder.
Here's what I thought of:
- Don't use UIBinder and build the TabLayoutPanel programmatically.
- Use UIBinder and just hide certain tabs based on each users role (which sounds like it would be quite inefficient).
Or are there better ways to achieve something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会选择第一种方法,因为它更干净,恕我直言。
但是,请确保您不将其用作安全功能,并且不显示任何不允许非管理员查看的敏感信息。由于所有构建都将在浏览器中的 JavaScript 中进行,因此在没有适当授权的情况下欺骗浏览器显示管理选项卡将相当简单。
I would go with approach number one as it is much cleaner, imho.
However, make sure that you don't use it as security feature and don't show any sensitive information that non admin is not allowed to see. Since all construction will occur in javascript in the browser, it will be fairly simple to fool browser into showing admin tabs without appropriate authorization.
我建议选项 2。GWT
生成较少量的 JavaScript,因为 UiBinder 中的选项卡可以转换为 HTML 和 CSS。
隐藏选项卡及其内容:
代码不多,但第二行确保除了选项卡内容之外,选项卡本身也被隐藏。
I suggest option 2.
GWT produces a smaller amount of JavaScript because the tabs in UiBinder can be turned into HTML and CSS.
To hide a tab and its content:
Not a pretty bit of code but the second line ensures the tab itself is hidden in addition to the tab's content.