Bonjour,
je voudrais colorier une DataTable de Primefaces avec plus de deux couleur et je ne vois pas comment faire.L'exemple suivant inspiré par :
http://www.primefaces.org/showcase/u...leColoring.jsf :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns="http://www.w3c.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="../../templates/consoles-admin/template.xhtml">
	<ui:define name="pagecontent">
		<p:panel>
			<h:form id="form">
 
 
 
				<p:dataTable id="table" var="car" value="#{tableBean.carsSmall}"
					rowStyleClass="#{car.year le 1980 ? 'highlightTableRowGray' : 'highlightTableRowGreen'}">
					<p:column>
						<f:facet name="header">  
                    Model  
            </f:facet>
						<h:outputText value="#{car.model}" />
					</p:column>
 
					<p:column>
						<f:facet name="header">  
                    Year  
            </f:facet>
						<h:outputText value="#{car.year}" />
					</p:column>
 
					<p:column>
						<f:facet name="header">  
                    Manufacturer  
            </f:facet>
						<h:outputText value="#{car.manufacturer}" />
					</p:column>
 
					<p:column>
						<f:facet name="header">  
                    Color  
            </f:facet>
						<h:outputText value="#{car.color}" />
					</p:column>
				</p:dataTable>
 
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
</html>
Avec le CSS suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.highlightTableRowGreen {
   background-color: green !important;
      font-weight: bold;
}
 
.highlightTableRowRed {
   background-color: red !important;
      font-weight: bold;
}
 
.highlightTableRowGray {
   background-color: gray !important;
      font-weight: bold;
}
Marche très bien.Ce que je voudrais faire c'est attribuer une couleur différente selon un critère qui peut avoir 3 valeurs distinctes.