Nacho321
Nacho321

Reputation: 1991

Conditional column rendering

I'm working with jsf 2.0. I have this datatable

<h:dataTable value="#{agreement.licenseProducts}"
    var="licenseProduct"
    styleClass="pnx-table pnx-table-bdr pnx-table-unstyled mp-license-info">
    <h:column>
        <f:facet name="header">
            <h:outputText value="Product" />
        </f:facet>
        <h:outputText value="#{licenseProduct.description}" />
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="Serial Number" />
        </f:facet>
        <h:outputText value="#{licenseProduct.serialNumber}" />
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="#{agreement.labelForConcurrency}" />
        </f:facet>
        <h:outputText value="#{licenseProduct.concurrent}" />
    </h:column>
    <ui:fragment rendered="#{agreement.managementTool != 'NONE'}">
        <h:column>
            <f:facet name="header">
                <h:outputText value="#{agreement.labelForLicenseType}" />
                <span class="pnx-icon-right pnx-icon-info pnx-tooltip">
                    <div class="pnx-tooltip-content">
                        <h:outputText value="Tooltip content" />
                    </div>
                </span>
            </f:facet>
            <h:outputText value="#{licenseProduct.licenseBase}" />
        </h:column>
    </ui:fragment>
    <h:column>
        <f:facet name="header">
            <h:outputText value="#{agreement.labelForSeatCount}" />
        </f:facet>
        <h:outputText value="#{licenseProduct.seats}" />
    </h:column>
</h:dataTable>

The problem is that the ui:fragment part is not working. No matter what the attribute's value is, it will NEVER show the column.

Any ideas?

--EDIT--

Just in case, I have other ui:fragments that depend on that same attribute, and they do render correctly depending on the attribute's value. I'm sure it has to do with the dataTable and the columns.

Upvotes: 0

Views: 5221

Answers (1)

Omar
Omar

Reputation: 1440

The rendered's attribute of <h:column> tag performs simply the job :

<h:column rendered="#{agreement.managementTool != 'NONE'}">
       ...        
</h:column>

Upvotes: 2

Related Questions