JSF - selectonemenu(nullPointer)

时间:2012-06-07 13:17:49

标签: jsf selectonemenu

表格摘要:

<h:selectOneMenu id="supervisor" value="#{newTopic.supervisor}">
                <s:objectConverter/>
                <f:selectItems value="#{supervisors}" var="_supervisor"
                               itemValue="#{_supervisor}"
                               itemLabel="#{_supervisor.name.firstName} #{_supervisor.name.lastName}"></f:selectItems>   
</h:selectOneMenu>
<h:commandButton action="#{newTopicAction.createTopic}" value="Create topic"/>

控制器操作:

@Model
public class NewTopicAction implements Serializable{
    @Inject
    private TopicManager topicManager;

    private ThesisTopic newTopic;

    public String createTopic(){
        topicManager.createTopic(newTopic);
        return "topics?faces-redirect=true";
    }

    @PostConstruct
    public void init(){
        newTopic = new ThesisTopic();
    }

    @Produces
    @Model
    public ThesisTopic getNewTopic(){
        return newTopic;
    }
}

为什么在调用newTopicAction.createTopic时,newTopic.supervisor不会填充选定的主管?除此之外,其他所有字段都按预期工作。这可能是关于selectOneMenu我不理解的东西。

0 个答案:

没有答案