I have following field in my jsp. Selected value is not set to the element. When I did Inspect element on this drop down field in FF, it shows that element is not selected. Also its not set to the backing bean. What am I missing?
<h:selectOnMenu id="scriptEngine" value="#{AddScriptBean.scriptEngine}" required="true">
<f:selectItems value="#{AddScriptBean.scriptEngines}"/>
</h:selectOneMenu>
The backing bean code is as follows
public List<SelectItem> getScriptEngines() {
List<SelectItem> items = new ArrayList<SelectItem>();
try {
GetScriptEngineNamesCommand command = (GetScriptEngineNamesCommand) CommandFactory.getInstance().getCommand(GetScriptEngineNamesCommand.class.getName());
command.doExecute();
Map<String, String> engineNames = command.getEngineNames();
MessageSource messageSource = getMessageSource();
Locale locale = RequestUtils.getUserLocale((HttpServletRequest) FacesContext.getCurrentInstance()
.getExternalContext().getRequest(), Globals.LOCALE_KEY);
String label = messageSource.getFormattedMessage(locale, "com.soa.console.faces.script.select", new Object[] {});
items.add(new SelectItem("", label));
for (String name : engineNames.keySet()){
items.add(new SelectItem(engineNames.get(name), name));
}
}catch (GException e){
String eMessage = e.toString();
FacesMessage msg = new FacesMessage("", eMessage);
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
return items;
}