2

I have this class in my Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8.

I have this in my JSP

<form:select id="statusKeyId" path="statusKey" cssStyle="width: 150px" >
    <form:option value="0"><fmt:message key="select.option.all"/></form:option>
    <c:forEach items="${allStatusList}" var="statusVar">
    <form:option value="${statusVar.key}" >                                                 
    <c:choose>
    <c:when test="${!(statusVar.name eq 'AWARDED') && !(statusVar.name eq 'CANCELLED') && !(statusVar.name eq 'IN_PROGRESS') && !(statusVar.name eq 'REFUSED')}" >
        &nbsp;&nbsp;<fmt:message  key="${statusVar.key}" />
    </c:when>
    <c:otherwise>
        <fmt:message  key="${statusVar.key}" />
    </c:otherwise>
    </c:choose>                                                                                                                                                                         
    </form:option>
    </c:forEach>                                    
</form:select>  

This is the source of the generated page :

<select id="statusKeyId" name="statusKey" style="width: 150px">
    <option value="0">All</option>                          
    <option value="AWARDED" selected="selected"> AWARDED </option>
    <option value="NO_PENDING_OPERATIONS"> &nbsp;&nbsp;No pending operations </option>
    <option value="IN_PROGRESS_EXTENSION"> &nbsp;&nbsp;With an In Progress Extension </option>
    <option value="WAITING_FOR_WITHDRAW"> &nbsp;&nbsp;Waiting for Tdk Permit Withdrawal </option>
    <option value="MODIFICATION_IN_PROGRESS"> &nbsp;&nbsp;With modification in progress </option>
    <option value="RENEWAL_REQUEST"> &nbsp;&nbsp;With a pending renewal request </option>
    <option value="DISCARDED">DISCARDED</option>
    <option value="Permit_DISCARDED_EXPIRY_PERMIT"> &nbsp;&nbsp;Expiry of Permit PERMIT </option>
    <option value="Permit_DISCARDED_HOLDER_WITHDRAWAL"> &nbsp;&nbsp;Award Holder Withdrawal </option>
    <option value="Permit_DISCARDED_NON_PAYMENT_FEES"> &nbsp;&nbsp;Non Payment of Fees </option>
    <option value="Permit_DISCARDED_OTHER"> &nbsp;&nbsp;Other </option>
    <option value="IN_PROGRESS">IN PROGRESS </option>
    <option value="REFUSED"> REFUSED </option>
</select>

As you see the option AWARDED is selected, but in the page the option 0 / ALL is selected

amicoderozer
  • 2,046
  • 6
  • 28
  • 44
Amadeu Cabanilles
  • 913
  • 3
  • 19
  • 47

1 Answers1

0

The HTML generated is fine, the issue is in the order of execution and rendering.

What you need to do is programatically create the HTML select element using JS. Something like https://stackoverflow.com/a/17002049/643500

Community
  • 1
  • 1
Sully
  • 14,672
  • 5
  • 54
  • 79