More then one condition in JSTL when?

IS there a way to combine the first three conditions in to one since they all set the same value??

<c:when test="${omni.content_type_media == null}">
<c:when test="${omni.content_type_media == '<ADD CONTENT>'}">
<c:when test="${omni.content_type_media == 'None'}">
----------------------------------------------------------------------------------
<c:choose>
                                          <c:when test="${omni.content_type_media == null}">
                                               <c:set var="content_type_media" value=""/>
                                            </c:when>
                                          <c:when test="${omni.content_type_media == '<ADD CONTENT>'}">
                                               <c:set var="content_type_media" value=""/>
                                            </c:when>
                                          <c:when test="${omni.content_type_media == 'None'}">
                                               <c:set var="content_type_media" value=""/>
                                            </c:when>
                                          <c:otherwise>
                                              <c:set var="content_type_media" value="${omni.content_type_media.value}"/>
                                            </c:otherwise>
                                    </c:choose>
894359Asked:
Who is Participating?
 
KruleCommented:
Err sorry, small brain lapse there, that should read:

<c:when test="${omni.content_type_media == null || omni.content_type_media == '<ADD CONTENT>' || omni.content_type_media == 'None'">
0
 
KruleCommented:
One option is to create a function in your Omni bean that looks like so:

public boolean isContentTypeMediaValid() {
  return content_type_media == null || content_type_media.equals("<ADD CONTENT>") || content_type_media.equals("None");
}

then use

<c:when test="${omni.contentTypeMediaValid}"> ...

Another solution would be to simply use the logical operators:

<c:when test="${omni.content_type_media == null or omni.content_type_media == '<ADD CONTENT>' or omni.content_type_media == 'None'">
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.