Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 如何在EL表达式中创建OR条件?_Jsf_Jsf 2_El - Fatal编程技术网

Jsf 如何在EL表达式中创建OR条件?

Jsf 如何在EL表达式中创建OR条件?,jsf,jsf-2,el,Jsf,Jsf 2,El,我想在此菜单中设置一个或条件: <li class="#{facesContext.viewRoot.viewId == ('/company/team.xhtml' or '/company/partnerships.xhtml' ) ? 'active' : '' }"><a class="item" href="company/company.xhtml">Company</a> <ul> <li><

我想在此菜单中设置一个或条件:

<li class="#{facesContext.viewRoot.viewId == ('/company/team.xhtml' or '/company/partnerships.xhtml' ) ? 'active' : '' }"><a class="item" href="company/company.xhtml">Company</a>
    <ul>
        <li><a href="company/team.xhtml">Team</a></li>
        <li><a href="company/partnerships.xhtml">Partnerships</a></li>
    </ul>
</li>

  • 如果用户选择了
    team.xthml
    partnerships.xhtml
    页面,则将在
  • 标记中设置“active”值。

    这是正确的语法:

    <li class="#{facesContext.viewRoot.viewId == '/company/team.xhtml' or facesContext.viewRoot.viewId == '/company/partnerships.xhtml' ? 'active' : '' }">
    
    为了使其更简短,您可以将
    {view.viewId}
    别名为:

    
    ...
    
  • <li class="#{view.viewId == '/company/team.xhtml' or view.viewId == '/company/partnerships.xhtml' ? 'active' : '' }">
    
    <c:set var="viewId" value="#{view.viewId}" scope="request" />
    ...
    <li class="#{viewId == '/company/team.xhtml' or viewId == '/company/partnerships.xhtml' ? 'active' : '' }">