JSF h:outputText基于用户角色呈现条件

时间:2013-01-10 12:16:27

标签: security jsf

我必须根据用户角色在JSF中渲染outputText outputText框是:

<h:outputText id="citizenaddress" value="#{customerView.customerCurrentAddress}" escape="false" rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}"></h:outputText>

web.xml是:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

,例外是:

javax.el.ELException: /info/citizenInfo.xhtml @42,193 rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}": Method userInRole not found

2 个答案:

答案 0 :(得分:1)

该方法为isUserInRole(String)

您可能会将bean属性的表达式规则与方法的语法混淆。

我相信表达应该是:

#{facesContext.externalContext.isUserInRole('isabletoGetCitizenAddress')}

答案 1 :(得分:0)

尝试将isabletoGetCitizenAddress的双引号更改为单引号。 <h:outputText id="citizenaddress" value="#{customerView.customerCurrentAddress}" escape="false" rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}"></h:outputText>