spring - how to use if loop inside if loop using jstl -


i have requirement if status 0 add css class active else add css class active1 , have done follow

<c:foreach items="${parentlist}" var="test">  <c:choose>   <c:when test="${test[1] eq 0}">    <li><a href="#" class="active" value="${test[0].id}-${test[0].category}" id="${parent.id}" onclick="return getquestions(this);" >  ${test[0].name }</a></li>   </c:when>    <c:otherwise>   <li><a href="#" class="active1" value="${test[0].id}-${test[0].category}" id="${parent.id}" onclick="return getquestions(this);" >  <img src="${pagecontext.request.contextpath}/resources/ui_resources/img/checked.jpg" alt="" height="20" width="20"/>${test[0].name }</a></li>   </c:otherwise> </c:choose> </c:foreach> 

now requirement if

${test[0].category} client add button <button name="delete/>

so 4 condtions arrise

  1. if status 0 , category not client add class active
  2. if status 0 , category client add class ="active" , add button.
  3. if status not 0 category client add class="active1" , add button
  4. if status not 0 , category not client add class="active".

so can body please tell me how use if loop inside if loop using jstl

instead of multitude of <c:choose /> use <c:if /> <c:var /> determine class use. can use <:if /> button, require move rendering of image css.

the jsp (from top of head).

<c:foreach items="${parentlist}" var="test">     <c:set var="clazz" value="active" />     <c:if test="${test[1] ne 0 , test[0].category ne 'client'}">         <c:set var="clazz" value="active1" />     </c:if>      <li>         <a href="#" class="${clazz}" value="${test[0].id}-${test[0].category}" id="${parent.id}" onclick="return getquestions(this);" > ${test[0].name }</a>         <c:if test="${test[0].category eq 'client'}"><button name="delete" /></c:if>     </li> </c:foreach> 

you need following css class active1

a.active1 {     background-image: url('/resources/ui_resources/img/checked.jpg');     background-repeat: no-repeat;     padding-left: 25px;  /* width of image plus little padding */     display: block; } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -