select bean支持bean中的selectManyCheckbox更新

时间:2018-02-11 17:38:14

标签: jsf primefaces

我在每张幻灯片上创建carousel组件,selectManyCheckbox

        <h:form>
            <p:carousel var="question" 
                        value="#{quizView.questions}" 
                        numVisible="1" 
                        responsive="true">
                <p:selectManyCheckbox 
                     value="#{question.options}"
                     layout="responsive"
                     columns="1">
                    <f:selectItems value="#{question.options}" 
                                   var="option" 
                                   itemLabel="#{option.text}"
                                   itemValue="#{option.text}"/>
                    <p:ajax listener="#{quizView.itemSelected}" update="@form"/>
                </p:selectManyCheckbox>
            </p:carousel>
        </h:form>

我想抓住支持bean的更改并更新选项对象上的属性。正确调用支持方法,但我不知道如何从这里移动:

public void itemSelected(AjaxBehaviorEvent event) {
    questions = questionService.getQuestions(quizURL);
    // figure which question from event
    // figure out which option from event
    // update the property on the option
}

Option类如下所示:

public class Option {
    private Boolean correct;
    private Boolean selected;
    private String text;

    // Getters and Setters
}

如果选择此选项,我希望将所选属性设置为 true

0 个答案:

没有答案