本文介绍了如何启用/禁用jsf/icefaces中的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找如何基于用户登录启用和禁用icefaces组件?例如:

I am looking for how to enable and disable the icefaces components based on the user login ?For example:

如果以管理员身份登录,我需要启用更多组件并以用户身份登录,请禁用某些组件以及在一页中添加其他组件?如何在jsf/icefaces中执行此功能?

if login as admin i need to enable the come more components and login as user, disable some components as well as add some other components in one page ? How to do this function in jsf/icefaces ?

这两个在一页中启用和禁用.

These two enable and disable in one page .

我很满意你的建议.

推荐答案

使用rendered属性.它接受一个布尔表达式.向User实体(如isAdmin()getRole())添加方法,并让rendered属性在其上拦截.

Use the rendered attribute. It accepts a boolean expression. Add a method to the User entity like isAdmin() or getRole() and let the rendered attribute intercept on that.

<h:someComponent rendered="#{user.admin}">
    Will be displayed when user.isAdmin() returns true.
</h:someComponent>
<h:someComponent rendered="#{user.role != 'ADMIN'}">
    Will be displayed when user.getRole() (String or enum) does not equal ADMIN.
</h:someComponent>

对于您感兴趣的情况,这里有一些更多的示例,说明了如何在EL中使用布尔表达式.

For the case you're interested, here are some more examples how you could use boolean expressions in EL.

与JSP兼容的语法:

<h:someComponent rendered="#{bean.booleanValue}" />
<h:someComponent rendered="#{bean.intValue > 10}" />
<h:someComponent rendered="#{bean.objectValue == null}" />
<h:someComponent rendered="#{bean.stringValue != 'someValue'}" />
<h:someComponent rendered="#{!empty bean.collectionValue}" />
<h:someComponent rendered="#{!bean.booleanValue && bean.intValue != 0}" />
<h:someComponent rendered="#{bean.enumValue == 'ONE' || bean.enumValue == 'TWO'}" />

与Facelets兼容的语法,其中包含一些 EL运算符(如>&)已更改:

Facelets-compatible syntax with some XML-sensitive EL operators like > and & changed:

<h:someComponent rendered="#{bean.booleanValue}" />
<h:someComponent rendered="#{bean.intValue gt 10}" />
<h:someComponent rendered="#{bean.objectValue eq null}" />
<h:someComponent rendered="#{bean.stringValue ne 'someValue'}" />
<h:someComponent rendered="#{not empty bean.collectionValue}" />
<h:someComponent rendered="#{not bean.booleanValue and bean.intValue ne 0}" />
<h:someComponent rendered="#{bean.enumValue eq 'ONE' or bean.enumValue eq 'TWO'}" />

这篇关于如何启用/禁用jsf/icefaces中的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 05:50