I'd like to change the background color of rows based on a condition.
<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>
If the value of "entry.action" is X I like to use "history-table-row-incomplete" (name of styleclass), if the value is Y I like to use "history-table-row-error" (name of styleclass). All other cases should use the default value.
I guess i have to get the current object of entry somehow to my bean, analyze it and return a string with the name of the stylclass to outputText to change the color. But I don't know how... (I'm new in JSF...)
Can someone help me please?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…