In a simple Spring 3 MVC app I have a few drop downs that don't show any options.
The jsp form snippet is:
<form:form method="POST" commandName="carSelection">
<form:errors path="*" cssClass="errorblock" element="div" />
<table>
<tr>
<td>Car Make :</td>
<td><form:select path="makes" multiple="false">
<form:options items="${makes}"/>
</form:select>
</td>
<td><form:errors path="makes" cssClass="error" /></td>
</tr>
<tr>
<td>Car Make (SimpleList):</td>
<td><form:select path="simpleModels" multiple="false">
<form:options items="${simpleModels}"/>
</form:select>
</td>
<td><form:errors path="makes" cssClass="error" /></td>
</tr>
<tr>
<td>Car Model :</td>
<td>
<form:select path="models" items="${models}" multiple="false">
<form:option value="NONE" label="--- Select ---" />
<form:options items="${models}" itemValue="modelId" itemLabel="modelName"/>
</form:select>
</td>
<td><form:errors path="models" cssClass="error" /></td>
</tr>
</table>
</form:form>
And the Controller class I have the following:
@Controller
@RequestMapping("/car")
public class CarController {
/**
* Initialise the car selection form
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/carSelectionForm")
public ModelAndView loginForm() throws Exception {
ModelAndView mav = new ModelAndView();
CarSelection cs = new CarSelection();
List<CarMake> makes = new ArrayList<CarMake>(5);
makes.add(new CarMake(1, "Ford"));
makes.add(new CarMake(2, "Fiat"));
makes.add(new CarMake(3, "Renualt"));
makes.add(new CarMake(4, "Kia"));
makes.add(new CarMake(5, "Ferrari"));
cs.setMakes(makes);
List<String> simpleList = new ArrayList<String>(5);
simpleList.add("Ford");
simpleList.add("Fiat");
simpleList.add("Renualt");
simpleList.add("Kia");
simpleList.add("Ferrari");
cs.setSimpleModels(simpleList);
mav.setViewName("carSelectionForm");
mav.addObject("carSelection", cs);
return mav;
}
}
The option for 'NONE' does render and is the only option that shows. Am I missing something basic?