1

I want to apply if condition on data retrieved through list onto JSP page using DisplayTag Suppose We have a list object 'Alist'. This object is a part of DisplayTag table. Table has pagination enabled.

<display:table class="displayTable" cellpadding="0" cellspacing="0" id="Alist" name="Alist" pagesize="20" requestURI="${pageContext.request.contextPath}/Action.do?csrf=<%=csrfPage%>">
<display:setProperty name="paging.banner.placement" value="both" /> 

Now in this we have display tags like below :

<display:column class="normal_text" property="NUMBER" title="Number" />

Now I would like to change value of property NUMBER based on various conditions. I am new to DisplayTag. Please guide me to solve this issue.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Cast_A_Way
  • 472
  • 5
  • 19

1 Answers1

0

You can go like : For single condtion :

<c:if test="${<your_condition>}">
    <display:column class="normal_text" property="NUMBER" title="Number" />
</c:if>

For multiple conditions :

<c:choose>
      <c:when test="${<condition_1>}">
       <display:column class="normal_text"property="NUMBER"title="Number"/>
      </c:when>
      <c:when test="${<condition_2>}">
         <display:column class="normal_text"property="NUMBER"title="Number"/>
      </c:when>
      <c:when test="${<condition_3>}">
         <display:column class="normal_text"property="NUMBER"title="Number"/>
      </c:when>
      <c:otherwise>
         <default display if none of your condition was true>
      </c:otherwise>
</c:choose>

Where c is the prefix that you defined in your jsp page for JSTL tag lib.

Rajnikant Patel
  • 561
  • 3
  • 19
  • Thanks Rajnikant. My condition is ${AList.NUMBER == '919019029039'}. But it is not working. I can see both if conditions working. Why so? – Cast_A_Way Dec 15 '15 at 08:35
  • Can you share the code that you have prepared? So I can have proper idea. Sorry for late reply, I was on lunch break. – Rajnikant Patel Dec 15 '15 at 08:58