aspose file tools
The moose likes JSF and the fly likes h:dataTable rowClasses attribute can be used to colorise each row based on bean property value. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "h:dataTable rowClasses attribute can be used to colorise each row based on bean property value." Watch "h:dataTable rowClasses attribute can be used to colorise each row based on bean property value." New topic
Author

h:dataTable rowClasses attribute can be used to colorise each row based on bean property value.

Smitha Dsouza
Greenhorn

Joined: Feb 10, 2012
Posts: 3

Hi This post regarding h:dataTable rowClasses attribute.

Hope this will be useful for you also as i have used in my code.


Out put should be a Table with row colored depending on the status of the each student.

so in my jsp i addded
<style>
.redcolor{
background-color:rgb(250,128,114);
}
.blueColor{
background-color:rgb(135,206,250);
}
.yellowColor{
background-color:rgb(255,255,224);
}
.whiteColor{
background-color:white;
}
</style>
within the head tag and the table as
<h:dataTable id="UnAssignedTable" width="100%" value="#{studentAGAssign.studentBasicVOList}" var="item" rowClasses="#{studentAGAssign.rowColor}">
</h:dataTable>

In my bean file i added rowColor as String variable with its getter and setter methods.
and initialize the rowColor variable with the css class name specified in the jsp page according to each student status which is in the below java code using string builder:
StringBuilder strBuild=new StringBuilder();


for(StudentBasicVO student:studentBasicVOList){
strBuild.append(getRowColor(student));
strBuild.append(',');
}
int length= strBuild.length();
if(length>0){
strBuild.deleteCharAt(length-1);
// strBuild.append(';');
rowColor=new String(strBuild);
}
public String getRowColor(StudentBasicVO stu){
String rowColor="whiteColor";
if(stu.isApplied()){
rowColor="yellowColor" ;
}else if(stu.isConfirmed()){
rowColor="blueColor";
}else if(stu.isCompleted()){
rowColor="redColor";
}


return rowColor;
}



Please post your comments if anything new and more good can be done in this. :thumbup
Google:
h:dataTable rowClasses attribute
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:dataTable rowClasses attribute can be used to colorise each row based on bean property value.
 
Similar Threads
Can i customize JSF datatable with IBM RSA
radiobuttons changing background color
color row-x
error with tiles , please help
datatable - row colors