Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:42:53+00:00 2026-06-17T13:42:53+00:00

I have a Spring MVC form:select whose form:options are bind with a List<Custom_Object> .

  • 0

I have a Spring MVC form:select whose form:options are bind with a List<Custom_Object>. The List<Custom_Object> is named as LOCALIZATION_LIST in the code below.

The path attribute of form:select is used to set the selected option.

<form:form action="editNode.do" method="post" name="editNodeForm" commandName="editElementDetails">
  <table>
    <tr>
      <td>Data Type</td>
      <td>
       <form:select path="datatype" onchange="" cssClass="large" id="datatypes">
        <c:if test="${! empty LOCALIZATION_LIST}">
          <form:options items="${LOCALIZATION_LIST}" itemLabel="local_Name" itemValue="local_Name"/>
        </c:if>
       </form:select>
      </td>
    </tr>   
  </table>
</form:form>

Now my problem is that there might be a scenario when editElementDetails.datatype may contain a value which is not there in LOCALIZATION_LIST at all. So currently Spring MVC shows the first element of LOCALIZATION_LIST as selected.

Is there a way I can figure out whether the bind action for setting the selected object in form:options of form:select was successful or not?

So that when the binding was not successful, I can then add one extra form:option with the new value in the form.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:42:54+00:00Added an answer on June 17, 2026 at 1:42 pm

    Note: Answering my own question

    I figured it out for now by manually searching for the incoming command object field value in the LOCALIZATION_LIST and if not found, adding an extra form:option corresponding to it.

    I was hoping to find a JSTL/Spring-MVC out-of-box solution for this though.

    Here is the code:

    <form:form action="editNode.do" method="post" name="editNodeForm" commandName="editElementDetails">
      <table>
        <tr>
          <td>Data Type</td>
          <td>
           <form:select path="datatype" onchange="" cssClass="large" id="datatypes">
            <c:if test="${! empty LOCALIZATION_LIST}">
              <c:set var="contains" value="false" />
              <c:forEach var="item" items="${LOCALIZATION_LIST}">
                <c:if test="${item eq editElementDetails.datatype}">
                  <c:set var="contains" value="true" />
                </c:if>
              </c:forEach>
              <c:if test="${ !contains }">
                <form:option label="${editElementDetails.datatype}" value="${editElementDetails.datatype}"/>
              </c:if>
              <form:options items="${LOCALIZATION_LIST}" itemLabel="local_Name" itemValue="local_Name"/>
            </c:if>
           </form:select>
          </td>
        </tr>   
      </table>
    </form:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Spring MVC <form:select> tag in my JSP and have populated
I have a form in spring mvc 2 having command class Class1 I want
I am using Spring Web MVC for my application. I have 1 dropdown list
I have one page form done with Spring MVC. User has to register first
I am new to spring mvc and have seen examples where folks use @ModelAttribute(form)
I have basic Spring MVC 3 setup for i18n where I can show labels
I have a Spring MVC application which uses FreeMarker as View technology (But maybe
I have used spring MVC with JSP/JSTL for my previous application. I was going
I have a Spring MVC application trying to use a rich domain model, with
I have a spring mvc application that I have broken up into separate maven

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.