我想根据条件更改行的背景颜色.
<t:dataTable id="data"
styleClass="history-table"
headerClass="history-table-header"
rowClasses="history-table-row-default"
border="2" cellpadding="5" cellspacing="2"
var="entry"
value="#{historyBean.logEntryList}"
preserveDataModel="false"
rows="#{historyBean.history.rowCount}"
sortable="true">
<h:column>
<f:facet name="header">
<h:outputText value="Debug Status" />
</f:facet>
<h:outputText value="#{entry.action}" />
</h:column>
Run Code Online (Sandbox Code Playgroud)
如果"entry.action"值十一喜欢用"历史表 - 行 - 未完成"(的styleClass的名字),如果该值是YI喜欢用"历史表 - 行 - 错误"的styleClass的(名).所有其他情况应使用默认值.
我想我必须以某种方式获取当前的入口对象到我的bean,分析它并返回一个带有stylclass名称的字符串到outputText来改变颜色.但我不知道如何......(我是JSF的新人...)
有谁可以帮助我吗?
Bal*_*usC 12
使用而不是的rowStyleClass属性.将在每行的基础,其中评估是可用的,而仅在每个表的基础上进行评估.<t:dataTable>rowClassesrowStyleClassvar="entry"rowClasses
<t:dataTable ... rowStyleClass="#{entry.action == 'X' ? 'history-table-row-incomplete' : (entry.action == 'Y' ? 'history-table-row-error' : 'history-table-row-default')}">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15546 次 |
| 最近记录: |