【问题标题】:JSF composite component value and <c:if> [duplicate]JSF 复合组件值和 <c:if> [重复]
【发布时间】:2015-07-28 22:45:54
【问题描述】:

我有以下几点:

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

其中“xyz-mode”来自另一个复合组件... 当我使用这个打印它的值时:

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

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

<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 天了,我还没有找到答案:( .. 有人可以帮忙吗? 赞赏。

【问题讨论】:

    标签: jsf jstl composite-component


    【解决方案1】:

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

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

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2012-04-08
      • 2013-03-23
      • 2013-04-22
      • 2011-06-04
      • 1970-01-01
      • 2011-06-27
      • 2017-08-09
      • 2012-09-03
      • 2011-10-21
      相关资源
      最近更新 更多