1

There is any possible to restrict the data display in the datable based on c:if .

Let say

Output shown now:

Startdate     end date   status    Edit

2012-02-02    2012-03-02 Waiting   edit

2012-02-03    2012-03-04 Approved   edit

Output Expected:

Startdate     end date   status    Edit

2012-02-02    2012-03-02 Waiting   edit

2012-02-03    2012-03-04 Approved  

When the status is Waiting then the edit link should be shown.when it is rejected or approved then the edit link should not be shown

This is my Xhtml file.

           <h:form>
      <h:dataTable value="#{employeeleave}" var="e"
            styleClass="order-table"
            headerClass="order-table-header"
            rowClasses="order-table-odd-row,order-table-even-row"
            columnClasses="order-table-odd-column,order-table-even-column"
        >

        <h:column>
            <f:facet name="header">
                Start Date
            </f:facet>
                #{e.startDate}
        </h:column>

        <h:column>
            <f:facet name="header">
                End Date
            </f:facet>
                #{e.endDate}
        </h:column>

        <h:column>
            <f:facet name="header">
                Reason
            </f:facet>
                #{e.reason}
        </h:column>

        <h:column>
            <f:facet name="header">
                Status
            </f:facet>
                #{e.status}
        </h:column>
            <h:column>
        <f:facet name="header">
            Edit
        </f:facet>
        <c:if test="${e.status == 'Waiting'}">
        <p:commandLink value="Edit" action="editLeave" id="editleave" >
        <f:setPropertyActionListener value="#{e}" target="#{employeeDetails.employeeLeaveSelected}" />
        </p:commandLink>
        </c:if>
        </h:column>
    </h:dataTable>  
    </h:form>
bharathi
  • 6,019
  • 23
  • 90
  • 152

1 Answers1

2

JSTL tags doesn't work that way. They runs during view build time, not during view render time which is what you seem to expect. The ${e} is not available during view build time and would in your particular case thus always resolve to null.

You need to use the JSF component's rendered attribute instead.

Replace

<c:if test="${e.status == 'Waiting'}">
    <p:commandLink value="Edit" action="editLeave" id="editleave" >
        <f:setPropertyActionListener value="#{e}" target="#{employeeDetails.employeeLeaveSelected}" />
    </p:commandLink>
</c:if>

by

<p:commandLink value="Edit" action="editLeave" id="editleave" rendered="#{e.status == 'Waiting'}">
    <f:setPropertyActionListener value="#{e}" target="#{employeeDetails.employeeLeaveSelected}" />
</p:commandLink>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555