How can I change the style of a particular row based on a condition? I can use JSF EL in rich:column style class attribute, but I have to write for each column. I want to change
When using h:datatable, create a bean method and call this to determine the style. Perhaps this could also be done for a rich:datatable?
public String getStyleSelectedOrderRows() {
StringBuilder sb = new StringBuilder();
String[] oddEven = new String[]{"oddRow,", "evenRow,"};
int i = 0;
for (MyObject object: myObjectList) {
sb.append(object.isSelected() ? "selected," : oddEven[i++ % 2]);
}
return sb.toString();
}
and in the .xhtml: