JSF复合组件值和< c:if> [英] JSF composite component value and <c:if>

查看:72
本文介绍了JSF复合组件值和< c:if>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容:

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

其中"xyz-mode"来自另一个复合组件... 当我使用以下命令打印其值时:

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

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

它正确打印,假设值为3 但是..在同一页面中,当我使用c:if或c:when ..时,它无法正确评估该值:

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>

该代码仅打印其他"情况..而不是模式为3" 请注意,从复合组件中检索到的"xyz-mode"的类型为Integer. 为什么会这样呢.. 到现在已经10天了,我找不到答案了:( ..有人可以帮忙吗? 赞赏.

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.

推荐答案

您可以使用rendered属性检查条件并相应地打印值.

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}" />

希望有帮助.

这篇关于JSF复合组件值和&lt; c:if&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆