1

Form snippet:

<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"/>

Controller action:

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

Why isn't newTopic.supervisor populated with selected supervisor, when newTopicAction.createTopic is invoked? Every other field works as expected, except this one. It may be something about selectOneMenu what i don't understand properly.

4

0 回答 0