This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

retaining selected value of Drop Down Box

Dec 19th, 2010, 10:58 PM

Hi,

I have a simple user registration form (register.jsp) with some textboxes and dropdown boxes. All the user info. is collected using a java class "User". I am able to bind the User class with "register.jsp" using a servlet "RegisterController.java". I want to retain values inside the textbox and dropdown box after the page postback i.e. when form reloads after submit (may be to show some errors like "compulsory fields kept blank by user etc..) So far I am able to retain values of textbox using <spring:bind path="">
tag and ${status.value} expression. But this approach does not work for the dropdowns. Dropdown resets itself to the default(0 th) value after postback.
How to retain selected value of a dropdown? and also for radio buttons and checkboxes?

Further I am using an enum for drop down choices. So how to bind enum with the HTML/JSP drop down tags i.e. select tag?