Setting css classes on regular and header table cells

From: Lotus118 <>
Date: Tue, 9 Sep 2008 05:31:29 -0700 (PDT)

I have a question about the way that regular and header table cell css
classes are handled by the regular Mojarra release (I'm using version

First, if you want to set css classes on table cells by column, you have to
specify the "columnClasses" attribute on your datatable. In the standard
datatable, this attribute takes something of an all-or-nothing approach.
Either all your cells have a class, or none of them do. It's impossible to,
as I wanted to in a project last week, have just the last column of your
table be assigned a certain class. You could use, say for a four-column
table, 'columnClasses=",,,last"', but that renders unnecessary markup bloat
in the form of 'class=""' for every class-less column. Not pretty.

The second issue concerns how header cell classes are treated. This turns
out to be amazingly simple and intuitive compared to normal cell classes:
just set the "headerClass" attribute on the f:column tag (that's where you'd
expect to be able to set that value) and you're done.

I'm a little confused as to why the datatable takes two different approaches
to the same problem for two different types of cells. It seems to me that
either both css class values are set using the "columnClasses" String array
method, or both should be settable on the column tag. The latter would have
my preference (I think it's much more intuitive, as I said), as it would
greatly ease the process of setting just one column class in a clean
fashion. The way I had to do it now was subclass the TableRenderer and
modify the "renderRow" method so that it wouldn't output all the 'class=""'

So, anyone care to weigh in on this? I'd be happy to code up the patches if
people think adding a "styleClass" attribute, or something similar, to the
column tag is a good idea.

View this message in context:
Sent from the javaserverfaces dev mailing list archive at