我可以编写一个返回布尔值作为表达式的方法

时间:2012-01-19 09:18:52

标签: jsf

我可以这样写:

<ui:repeat var="element" value="mybean.list">
<h:outputLink styleClass="#{myBean.otherList.contains(element)?'someclass':'someotherclass'}" />
</ui:repeat>

1 个答案:

答案 0 :(得分:1)

我认为您需要的是将myBean.otherList.contains(element)用另一个括号()包裹起来,就像这样(myBean.otherList.contains(element))

我在几个地方做同样的事情

这里有一个例子

<h:panelGroup styleClass="#{(appRow.application.file)?'attachmentFileExist':'attachmentFileNotExist'}"></h:panelGroup>

这是你应该如何看待

<ui:repeat var="element" value="mybean.list">
    <h:outputLink styleClass="#{(myBean.otherList.contains(element))?'someclass':'someotherclass'}" />
</ui:repeat>

再次,不确定额外的括号,但我在我的页面中使用它们

为了检查代码,请使用浏览器或firebug的开发工具,只需单击单元格即可查看它的样式类