I'm creating a carousel
component, with selectManyCheckbox
on each slide:
<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>
I would like to catch the change on the backing bean and update the property on the option object. Backing method is called correctly, but I don't know how to move from here:
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
}
the Option
class looks as follows:
public class Option {
private Boolean correct;
private Boolean selected;
private String text;
// Getters and Setters
}
What I would like is to set the property selected to true if this option is selected