我在jsp中有以下字段。选定的值未设置为元素。 当我在FF中的这个下拉字段上检查了元素时,它显示该元素未被选中。也没有设置为后台bean。 我错过了什么?没有设置为支持bean的选择元素
<h:selectOnMenu id="scriptEngine" value="#{AddScriptBean.scriptEngine}" required="true">
<f:selectItems value="#{AddScriptBean.scriptEngines}"/>
</h:selectOneMenu>
的支持bean代码如下
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;
}
编辑器提供了一个“代码示例”按钮。或者只是开始有4个空格的行。这样编辑就不会试图净化你的文字。 – SJuan76 2013-05-13 02:03:07
另外,请访问常见问题解答 – SJuan76 2013-05-13 02:03:40
也分享支持bean的代码... – 2013-05-13 03:54:31