File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes columnClasses in HtmlDataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "columnClasses in HtmlDataTable" Watch "columnClasses in HtmlDataTable" New topic
Author

columnClasses in HtmlDataTable

seb petterson
Ranch Hand

Joined: Mar 04, 2005
Posts: 118
Is there a way to tell a dataTable that the styles you declare are to belong to the columns you declare in in jsf tags in the order they appear, and not simply to the columns that are rendered?

In this example if #{rules.col2Rendered} returns false and the others return true, then the styles col1, col2 will be assigned to the columns with id "col1" and "col3" since theyre the only ones rendered, instead I want these to have the styleClasses col1 and col3. How do I achieve this?

[ September 12, 2005: Message edited by: seb petterson ]
[ September 12, 2005: Message edited by: seb petterson ]
seb petterson
Ranch Hand

Joined: Mar 04, 2005
Posts: 118
I guess there is not. Instead I will get a string for columnClasses from bean method that calculates which styleclasses should be used. I don't like to have stuff that I feel belongs in web content files (jsps etc.) in java code, but oh well.
Bernard Perchman
Greenhorn

Joined: Jul 29, 2008
Posts: 4
For what it's worth, you'll want to use the <h:dataTable> tag instead; that caters for repeating rows.
Srinivas Krishnamoorthy
Greenhorn

Joined: Jul 28, 2008
Posts: 5
Originally posted by seb petterson:
I guess there is not. Instead I will get a string for columnClasses from bean method that calculates which styleclasses should be used. I don't like to have stuff that I feel belongs in web content files (jsps etc.) in java code, but oh well.


Yes, the work around you suggested is the best way to do it. I have done in lot of pages (even it costs specifing the styleclass name in the java file)
Puneet Swarup
Greenhorn

Joined: Jun 23, 2008
Posts: 1
why dont you use the condition and respective column classes within columnClasses attribute.

i mean [B][/B]

Hope this works.
Jerwin Louise Uy
Ranch Hand

Joined: Oct 27, 2007
Posts: 75
One possible workaround is to filter the list prior to rendering, i.e. have a copy of the list and the set the filtered list to the data table so that you can still use the columnClasses attribute in the data table.


Uy Jerwin Louise Vergara
Junior Developer / Research and Development at Incuventure Partners Corporation
email: jerwin.uy@incuventure.net
Miguel�ngel Fern�ndez
Greenhorn

Joined: Jun 08, 2007
Posts: 3
I had the same problem and I just tried Puneet Swarup's solution -which I believe to be the most elegant of the ones proposed thus far here. It worked perfectly. I had struggled to try to do the same with the A?B:C conditional notation but had failed time and time again. I would have continued to bang my head against the wall for hours had it not been for this thread. I never would have imagined that I had to enclose the columnClasses values in simple apostrophes ('). It's still a little confusing to me when to and not to use apostrophes. So, thanks a million, Swarup.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: columnClasses in HtmlDataTable
 
Similar Threads
How to use datatable with no records in a list
Problem in using rich:tree in IE6.0
nested h:datatable question
sending values to java script
creating a product list in JSF