C: select with multiple c: when - pass switch

If I have this code on my jsf page:

<c:choose>
    <c:when test="${empty example1}">
    </c:when>

    <c:when test="${empty example2}">
    </c:when>

    <c:otherwise>
    </c:otherwise>     
</c:choose>

it will work as a java operator switchwith caseand break- if at first, when it is true, the second test will not, right?

What should I write to get the operator switchwith case, but without break":

when the first C:whenis true, something adds to the page, and when the second is true, something is added to the page too

+4
source share
2 answers

, , , . <c:choose>, if-else.... JSTL .

<c:if>, or.

<c:if test="#{empty example1}">
    ...
</c:if>
<c:if test="#{empty example1 or empty example2}">
    ...
</c:if>
<c:if test="#{empty example1 or empty example2 or empty example3}">
    ...
</c:if>
...

JSF, rendered.

<h:panelGroup rendered="#{empty example1}">
    ...
</h:panelGroup>
<h:panelGroup rendered="#{empty example1 or empty example2}">
    ...
</h:panelGroup>
<h:panelGroup rendered="#{empty example1 or empty example2 or empty example3}">
    ...
</h:panelGroup>
...

, , . , <h:dataTable> , <c:if> , . . JSTL JSF2 Facelets... ?

, <c:set> EL. .

<c:set var="show1" value="#{empty example1}" />
<c:set var="show2" value="#{show1 or empty example2}" />
<c:set var="show3" value="#{show2 or empty example3}" />

<h:panelGroup rendered="#{show1}">
    ...
</h:panelGroup>
<h:panelGroup rendered="#{show2}">
    ...
</h:panelGroup>
<h:panelGroup rendered="#{show3}">
    ...
</h:panelGroup>
...
+9

, c:when. c:if:

<c:if test="${empty example1}">
      "example1 empty"
</c:if>

<c:if test="${empty example2}">
     "example2 empty"
</c:if>

<c:if test="${not empty example1 and not empty example2}">
     "both not empty"
</c:if>
+2

All Articles