Hello Everyone,
I have come across a issue which I think needs to be solved however I
wanted to get some input from the community before opening up a JIRA issue
and providing a patch.
Sample JSF page:
<h:outputStylesheet library="css"
name="table-style.css" />
<h:dataTable value="#{dataTableBean.sampleList}" var="o"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
columnClasses="col0,col1,col2,col3"
>
<f:param id="testParam" value="TESTER" />
<h:column>
<f:facet name="header">Column1</f:facet>
#{o.str1}
</h:column>
<h:column>
<f:facet name="header">Column2</f:facet>
#{o.str2}
</h:column>
<h:column>
<f:facet name="header">Column3</f:facet>
#{o.str3}
</h:column>
<h:column>
<f:facet name="header">Column4</f:facet>
#{o.str4}
</h:column>
</h:dataTable>
Sample CSS:
.order-table{
border-collapse:collapse;
}
.order-table-header{
text-align:center;
}
.order-table-odd-row{
text-align:center;
}
.order-table-even-row{
text-align:center;
}
.col0{
text-align:center;
}
.col1{
text-align:center;
}
.col2{
text-align:center;
}
.col3{
text-align:center;
}
Problem description:
The rendered output of one of the rows of the above page is the following:
<tr class="order-table-odd-row"><td class="col1">
test1
</td><td
class="col2">
test2
</td><td
class="col3">
test3
</td><td
class="">
test4
</td></tr>
As you can see the last column has no definition of a columnClass
( class="" ). The same page works if we remove the <f:param/> definition
from within the
<h:dataTable/>. If the f:param tag is removed then I see that all of the
columns have a defined class as expected ( the number of columns is less
than or equal to the
defined columnClasses so each of the columns should have a class defined.
>From looking over the code quickly I see that the problem most likely is
in the
HtmlTableRendererBase.encodeInnerHtml(....) method. In this method I see
the following:
List children = getChildren(component);
for (int j = 0, size = getChildCount(component); j < size;
j++)
{
UIComponent child = (UIComponent) children.get(j);
if (child.isRendered())
{
boolean columnRendering = child instanceof
UIColumn;
if (columnRendering)
beforeColumn(facesContext, uiData, j);
encodeColumnChild(facesContext, writer, uiData,
child, styles, nc * uiData.getChildCount() + j); // The first child is the
f:param and even though this is
// not a UIColumn component the next index
that
we pass in
// is incremented and that is the reason for
the class starting at 1 rather
// than 0 as it should. I think we need to
have an additional counter that
// only increments when a UIColumn is
rendered
as to keep the correct ColumnClasses
if (columnRendering)
afterColumn(facesContext, uiData, j);
}
}
I just wanted to reach out and get some input on this one. If I remove
the f:parm tag then everything renders as expected with the class starting
at col0 and going to col3.
If the community agrees I'll open up a JIRA issue and provide a patch for
this issue.
Thanks,
Paul Nicolucci