JSF composite component value and <c:if> [duplicate]

天大地大妈咪最大 提交于 2019-12-13 07:06:11

问题


I have the following:

<c:set var="myMode" value="#{component.parent.attributes['xyz-mode']}"/>

where "xyz-mode" is from another composite component... when I print its value using this:

<p:outputLabel value="#{myMode}" /> 

It prints it correctly, suppose the value is 3 But..in the same page, when I use c:if or c:when.. it does not evaluate the value correctly:

<c:choose>    
    <c:when test="#{myMode == 3}">
         <p:outputLabel value="mode is 3" />
    </c:when>
    <c:otherwise>
         <p:outputLabel value="Otherwise" />
    </c:otherwise>
</c:choose>

The code prints the "Otherwise" case only.. not the "mode is 3" Please note that the type of "xyz-mode" that is retrieved from the composite component is Integer.. Why this is happening.. It has been 10 days now and I am not finding the answer :( .. can anyone help please? Appreciated.


回答1:


You can use rendered attribute to check the condition and print the value accordingly.

<p:outputLabel value="mode is 3" rendered="#{myMode == 3}" />
<p:outputLabel value="Otherwise" rendered="#{myMode != 3}" />

Hope it helps.



来源:https://stackoverflow.com/questions/30286107/jsf-composite-component-value-and-cif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!