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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

path will only add id="statusKey" name="statusKey". Are you using JQuery?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.