my dog learned polymorphism
The moose likes JSF and the fly likes Datatable Conditional Row Colors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Datatable Conditional Row Colors" Watch "Datatable Conditional Row Colors" New topic

Datatable Conditional Row Colors

Muhammad Ijaz
Ranch Hand

Joined: Mar 03, 2009
Posts: 34

I am using the rich:datatable in which I need each row color based on some condition

Now each row should be of a color depending on 'patient.status' value of that row.
for example, if it is hospital patient- it should be blue color, if it is private patient - it should be sky blue color......

Any help will be highly appreciated.

IBM Certified WebSphere Commerce Application Developer

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

I can think of a solution here but that will violate the rule of concerns "Presentation and Business layer"

You can have some style classes each for a type of color. Now depending on the type of 'patient.status' you will set the property which is used to represent the styleClass.

I assume that you are using a patient Value Object/DTO.
styleClass attribute takes EL expression. I think it takes but not very sure of it. Its a long time I used it.


My Blog SCJP 5 SCWCD 5
I agree. Here's the link:
subject: Datatable Conditional Row Colors
jQuery in Action, 3rd edition