I'm using bootsFaces in JSF and I want to display in a column things like:
- if type value = 0 -> pending
- if type value = 1 -> accepted
- if type value = 2 -> rejected
- if type value = 3 -> completed
Each result (pending, accepted, rejected, completed) will be colored or printed like a button with different colors, not just a text.
<h:form>
<b:dataTable value="#{appointmentBean.yoursAppointments}" var="uapp">
<f:facet name="header">
<tr>
<th>#ID</th>
<th>Center name</th>
<th>Creation date</th>
<th>Appointment date</th>
<th>Last update</th>
<th>Type</th>
<th>Status</th>
</tr>
</f:facet>
<b:dataTableColumn value="#{uapp.idappointment}" order="asc"/>
<b:dataTableColumn value="#{uapp.idcenter}" />
<b:dataTableColumn value="#{uapp.creationDate}" />
<b:dataTableColumn value="#{uapp.appointmentDate}" />
<b:dataTableColumn value="#{uapp.lastUpdate}" />
<b:dataTableColumn value="#{uapp.type}" />
<b:dataTableColumn value="#{uapp.status}" />
</b:dataTable>
</h:form>
So, depending by <b:dataTableColumn value="#{uapp.type}" /> value I want to show some things, how can I do this in JSF using bootsFaces? Thanks!
I would use the
b:dataTablerow-style-classattribute for this. You can use EL in the value, as well as thevarattribute. So you could do something like:This allows you to style anything in rows, depending on the type. For example:
If you just need to style your type cell, you could simply do: