Re: Setting css classes on regular and header table cells

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Tue, 09 Sep 2008 09:27:09 -0700

This sounds a lot like spec issue 217 [1]. It's set to be addressed in 2.0.

Unfortunately, we can't make a similar change to 1.2 since it does require
a specification change (new attributes to a tag, etc).

That said, if you really need this, you could take the source for the
tag and
the current renderer and customize for your needs or I'm sure there is a
3rd party table that you might be able to use (like Woodstock).


Lotus118 wrote:
> Hi,
> 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
> 1.2_09).
> 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=""'
> markup.
> 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.
> Regards,
> Maarten