根据 GWT 中的用户角色处理元素属性

Handling element attributes based on user roles in GWT

我正在尝试解决基于 GWT 的应用程序中非常常见的情况。

If user has role 'ROLE_A', then show him only 'Search' button. All the other buttons will be disabled.

我正在使用 GWT 2.4.0Spring 3.0.5

任何指点将不胜感激。

我做这件事的方式(我认为应该怎么做,真的)是包括角色 into the HTML host page, rather than getting them through an additional request. Have a look at my dagger-guice-rf-activities archetype 作为示例(使用 Guice 和 Servlets 安全性,但很容易转换为 Spring)

然后在客户端上,使用普通的 Java ifs 来处理 UI。对于应用程序中只有部分用户会 see/use 的大部分,使用代码拆分,这样其他用户就不必下载太多代码。