Reputation: 1588
I'm trying to implement a JSTL logic which displayed submit buttons based on the following logic:
<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>
But unfortunately I get 2 buttons - buyx
buyz
. These buttons are displayed together. Only one button should be displayed.
Is there some way to implement the code in a way to display just one button at a time?
Upvotes: 0
Views: 65
Reputation: 12337
Is there some way to implement the code in a way to display just one button at a time?
Yes there is, by not using the jstl c:when
in a weird nested way but wrapping the inner ones in a c:choose
or changing them to c:if
's.
Off-topic the commandButtons in them look weird.
Upvotes: 3