【问题标题】:Implement logic to show only one button实现逻辑以仅显示一个按钮
【发布时间】:2020-05-09 05:06:26
【问题描述】:

我正在尝试实现一个 JSTL 逻辑,它根据以下逻辑显示提交按钮:

<c:choose>
            <!--  if it's demo mode skip every limit check, if not check them -->
            <c:when test="#{dashboard.demoMode == 'false'}">
                    <c:when test="#{dashboard.allowedTrades == 0}">
                           <h:commandButton id="buyx" x:data-toggle="modal" x:data-target="#hitsModal" />    
                    </c:when>

                    <c:when test="#{dashboard.currentBalance == 0}">
                           <h:commandButton id="buyz" x:data-toggle="modal" x:data-target="#chargeModal" />
                    </c:when>
            </c:when>

            <c:otherwise>
                   <h:commandButton id="buy" action="#{dashboard.calculateProcessing}" />
            </c:otherwise>
    </c:choose>

但不幸的是,我得到了 2 个按钮 - buyx buyz。这些按钮一起显示。应该只显示一个按钮。

有没有办法实现代码一次只显示一个按钮?

【问题讨论】:

  • 内部c:when标签也应该有自己的容器c:choose标签。
  • @TheBitman:就像在我的回答中一样...您可以投票...原始发布者将接受答案,我们很可能不会再收到他的消息(他一直在线17 分钟前未提供任何反馈)
  • @Kukeltje 这次只是为了你,因为你给了我一个答案:我不回答是因为我在工作。我稍后会在家里测试它。
  • 但即使是这种反馈也值得赞赏......总是......所以我们知道(将要)采取行动......谢谢

标签: jsf jsf-2 jstl


【解决方案1】:

有没有办法实现代码一次只显示一个按钮?

是的,不以奇怪的嵌套方式使用 jstl c:when,而是将内部的 c:choose 包裹起来或将它们更改为 c:if

题外话,其中的命令按钮看起来很奇怪。

【讨论】:

    猜你喜欢
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    • 2013-12-06
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多