English 中文(简体)
如何将参数传送到已设定的属性?
原标题:How to pass a parameter into rendered attribute?

我尝试将参数传送到方法管理员中, 像这样 :

<p:toolbarGroup align="right" rendered="#{loginBean.admin( dataread }">
                            <h:form>
                                <p:commandButton value="manage users" ajax="false"
                                                 icon="ui-icon-document" action="/admin/manageUsers.xhtml?faces-redirect=true"/>
                            </h:form>
                        </p:toolbarGroup>

我经管的豆子的代码就是那样

public boolean isAdmin(String role){
          FacesContext facesContext = FacesContext.getCurrentInstance();
          HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
          return request.isUserInRole("admin");                
          }
问题回答
rendered="#{loginBean.admin( dataread }"

您在那里看到缺少的 < code> > a EL 语法错误, 导致该值不被识别为 EL 表达式, 因此被当作普通香草字符串, 在 < code> rendered 中, 默认给布林 < code> true 。 另外, 在指定诸如 < code\bean. ethod ()\\\/ code > 这样的动作表达式时, 您应该指定完整的方法名称, 因此 isAdmin () 而不是 < code > admin ()

所有这些都应该做到:

rendered="#{loginBean.isAdmin( dataread )}"

与具体问题无关的<强度> , HtpServlet request 已在EL 范围内由提供,因此,这样做也不必支持豆锅炉板:

rendered="#{request.isUserInRole( admin )}"

< 强度 > 校正语法 :

rendered="#{loginBean.isAdmin( dataread )}">

代替

rendered="#{loginBean.admin( dataread }"

确保您的 EL 支持此特性 :

 <dependency>
      <groupId>org.glassfish.web</groupId>
      <artifactId>el-impl</artifactId>
      <version>2.2</version>
 </dependency>

寻找更多信息, 包括JSF中路由参数的教程:

  • < a href=" "http://www.mkyong.com/jsf2/how-to-pass-paraters-in-method- in-method-表达-jsf-2-0/"rel="nown" > 如何通过方法表达式中的参数 - JSF 2.0

  • 的途径





相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签