I am developing a web app using JSF 2. My web app among other things contains a series of questions put one at a time (so one question is visible at a time) and have multip
Simplest way would be to just bind the value of the checkbox group to the currently iterated object instead of all checkbox groups to one and same parent bean property.
In code, just replace
value="#{gridPopUpBean.oneQuestionUserAnswerList}"
by
value="#{p.oneQuestionUserAnswerList}"
and make changes in the model accordingly.
Alternatively, you can also provide a Map
of all answers by question ID in the parent bean. Here's a kickoff example which uses more self-documenting variable names than you have, so that it's better understandable:
<ui:repeat value="#{bean.questions}" var="question">
...
<h:selectManyCheckbox value="#{bean.answers[question.id]}">
<f:selectItems value="#{question.answers}" />
</h:selectManyCheckbox>
...
</ui:repeat>
with e.g.
private Map<Long, Answer[]> answers = new HashMap<Long, Answer[]>();