0

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;
}
4

1 回答 1

0

我猜 getter 方法没有调用,因为您使用scriptEngines<f:selectItems>对 bean 进行了绑定标记,但您的 getter 方法是getScriptEngines()。它应该是 getscriptEngines()。这可能是问题所在

于 2013-05-13T05:51:13.287 回答