Using multiple boolean conditions in EL expression

无人久伴 提交于 2019-12-02 01:43:44

问题


I would like to know how can I combine multiple boolean coniditions in EL. I have following example and it is not working.

<x:someComponent rendered="#{bean.condition1} or #{bean.condition2}">

How can I use "OR" and "AND" logical operators in EL?


回答1:


The operator has to go inside the EL expression, not outside. You should see the #{...} as one big scope wherein various variables/conditions interact with each other.

<x:someComponent rendered="#{bean.condition1 or bean.condition2}">

See also:

  • Our EL wiki page
  • Conditionally displaying JSF components
  • How to conditionally render plain HTML elements like <div>s?



回答2:


The operator OR in an expression EL is ||.

Try this:

<ice:panelCollapsible  rendered ="#{mySessionBean.buttonVisibilities['myButton1'] || mySessionBean.buttonVisibilities['myButton2']}">

See this tutorial http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html

Regards



来源:https://stackoverflow.com/questions/11064412/using-multiple-boolean-conditions-in-el-expression

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!