开发者

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

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}" />
        &开发者_高级运维lt;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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜