JSTL <c:if> tag not working in JSF 1.1

3k views Asked by At

I am using JSF 1.1 and Tomahawk and Tomcat 6.0

<c:if test="${vo.type=1}">
    <t:commandLink action="#{Manager.openPatient}">
        <c:out value="${vo.patientId}"></c:out>
        <t:outputText value="#{vo.patientId}" />
        <f:param value="#{vo.id}" name="patientId"/>
    </t:commandLink>
</c:if>

I am trying to add conditions based on the type. If vo.type = 1 do call Patient. If vo.type = 2 do call Account and so on.

It seems that <c:if> tag is not working. Any ideas or pointers in resolving this would be appreciated.

1

There are 1 answers

5
BalusC On BEST ANSWER

Like as in normal Java, you need to compare with ==, not with =.

<c:if test="${vo.type == 1}">

Unrelated to the concrete problem, if the same functionality is achievable with pure JSF, then you should prefer that over using JSTL. In this particular case, you could just make use of the rendered attribute which is supported by every JSF HTML component. Get rid of <c:if> (and the superfluous <c:out>) and change the <t:commandLink> as follows:

<t:commandLink action="#{Manager.openPatient}" rendered="#{vo.type == 1}">
    <t:outputText value="#{vo.patientId}" />
    <f:param value="#{vo.id}" name="patientId"/>
</t:commandLink>