i have created a very generic jsf composite component which renders a primefaces dataTable from generic row data.
For each row which should be rendered i have a pojo named ColumnDescription which contains the header name and the row data index to get the data.
This works fine but now i have the request to allow optional converters to be set on the columns.
So i extended the ColumnDescription with a converterId. The problem is that i only have to attach the converter to the if the converterId in the ColumnDescription is not null.
First idea:
<h:outputText value="#{row[column.rowBeanProperty]}">
<c:if test="#{column.hasConverter}">
<f:converter converterId="#{column.converterId}" />
</c:if>
This did not work. The test in the if tag will not even be evaluated. I think this is because the different phases the jsp tag will be evaluated.
Second idea Use the rendered attribute for the condition
<h:outputText value="#{row[column.rowBeanProperty]}">
<ui:fragment rendered="#{column.hasConverter}">
<f:converter converterId="#{column.converterId}" />
</ui:fragment>
This does not work because the converter needs to e attached to a editable value component
TagException: /components/dataReport.xhtml @38,80 <f:converter> Parent not an instance of ValueHolder: com.sun.faces.facelets.tag.ui.ComponentRef@35b683c2
Is there any chance to add the converter conditionally?
Thanks in advance Sebastian