Search code examples
jsfprimefacesdatatabletablecolumnconditional-rendering

p:column rendered attribute does not seem to work with p:dataTable var


I have written a code like:

<p:column headerText="Edit" width="40" rendered="#{(leaveDetails.strLeaveStatus == 'Canceled') or (leaveDetails.strLeaveStatus == 'Availed')}">
    <p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" disabled="true" process="@this" update="leaveDataTable" immediate="false">
        <h:graphicImage url="resources/images/edit.JPG"/>
            <f:attribute name="userId" value="#{employee.name}"/>
            <f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
            <f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
            <f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
            <f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
            <f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
    </p:commandLink>
</p:column>

But the rendered attribute is not working for the condition. How can I use the logical operator to make the condition work?Using PrimeFaces 3.4.2


Solution

  • The best way I used to resolve my problem with the help of GOD BalusC is:

    <p:column headerText="Edit" width="40">
        <p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" process="@this" update="leaveDataTable" 
            immediate="false" disabled="#{(leaveDetails.strLeaveStatus == 'Canceled') or (leaveDetails.strLeaveStatus == 'Availed')}">
            <h:graphicImage url="resources/images/edit.JPG"/>
            <f:attribute name="userId" value="#{employee.name}"/>
            <f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
            <f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
            <f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
            <f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
            <f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
        </p:commandLink>
    </p:column>
    

    and it works as smooth as butter!