Hi,
I have developed a jsf component which allows to have n-columns in a datatable
to make cross tables. That component is currently implemented using the myfaces
components as a base which is working fine.
The component is working like this:
<x:dataTable value="#{data.rows}" var="row" >
<!-- just a column -->
<h:column>
<f:facet name="header">
<h:outputText value="fixed column" />
</f:facet>
<h:outputText value="#{row.attributeName}" />
</h:column>
<!-- new columns component renders a column for each element in data.columns
-->
<x:columns value="#{data.columns}" var="column">
<f:facet name="header">
<!-- row is not available! -->
<h:outputText value="#{column.label}" />
</f:facet>
<!-- row is also available -->
<h:outputText value="#{data.columnValue}" />
<f:facet name="footer">
<!-- row is not available! -->
<h:outputText value="#{column.footer}" />
</f:facet>
</x:columns>
</x:dataTable>
The x:columns component is based on UIData. The parent datatable must have a
fixed count of columns so it is not possible to use <x:columns
value="#{row.columns}" var="column">.
To get the value for the column in the row a managed bean must be used which
calls DataModel.getRowData() from the rows datamodel and the columns datamodel
to determine the current row and column.
I would like to contribute this component to myfaces.
Now to the tricky part which is the reason why I've not contributed the
component yet.
Currently the parent datatable component (which is doing the most work)
contains a lot of code copied from the UIData class which handles the
processing of the columns through private methods. The best place to integrate
the new columns component would be the UIData class but that would generate
dependencies to non standard components. I've also noticed that die myfaces
HtmlDataTable uses a HtmlDataTableHack class which copies the code from UIData
to make extended components work. I do not think that copying code is the best
solution since the last change in UIData was not applied to HtmlDataTableHack.
To prevent inconsistent code I suggest to introduce an abstract UIDataBase
class in share which contains the implementation of UIData and make the private
methods protected. UIData extends the UIDataBase with an empty implementation.
Some of the renderers do that already. I don't think it violates the spec.
Mathias