webtier@glassfish.java.net

Re: [webtier] Conditionally rendering h:column

From: Uwe Seimet <Uwe.Seimet_at_seimet.de>
Date: Thu, 12 Nov 2009 22:03:34 +0100

Hi Alex,

> You have to think of it in terms of how an HTML table is drawn, you
> cannot have a variable number of columns per row. If you have a dataset
> of 5 rows, and you're deciding the rendered attribute of h:column using
> data from the row item where it is not rendered in one row only, you'll
> be generating mal-formed HTML:
>
> <table>
> <tr><td>1</td><td>2</td</tr>
> <tr><td>1</td><td>2</td</tr>
> <tr><td>1</td><td>2</td</tr>
> <tr><td>1</td><td>2</td</tr>
> <tr><td>1</td>
> </table>
>
>
> Your condition for the rendered attribute of h:column can of course come
> from anywhere, but it must be true for your entire dataset (and as such,
> probably should not be derived from your iterated table data)

I see your point, and there is indeed the potential of generating
illegal HTML. In my case, however, the number of rendered columns was
constant while rendering the table. Nevertheless the rendered result
was incorrect. Provided that the count of rendered columns does not
change while rendering a particular table (i.e. #{item.rendered} always
returning the same value) I would have expected my code to work, but
despite the fact that #{item.rendered} always returned 'true' the table
was rendered incorrectly. I wonder why this happens and whether there is
a technical explanation.

Best regards

Uwe

-- 
-----------------------------------------------------------------------
  Dr. Uwe Seimet                                http://www.seimet.de/