I have a bean called Question with a lot of alternatives -->
Question have 1:N Alternative.
I have a Page with a lot of Question, like:
Page have 1:N Question
I need create a XHTML page showing the amount of questions and your alternatives, like this:
<c:forEach var="questaoCurso"
items="#{cursandoMB.paginaAtualProva.questoesCurso}">
<h:outputText value="#{questaoCurso.questao.texto}" />
<br />
<h:selectOneRadio style="font-weight: normal"
value="#{cursandoMB.alternativasEscolhida}" layout="pageDirection">
<f:selectItems value="#{questaoCurso.questao.alternativasPreenchidas}"
var="c"
itemValue="#{c}"
itemLabel="#{c.texto}" />
</h:selectOneRadio>
<br />
<br />
</c:forEach>
The problem is that I don't know how I can set each choose alternative in a List in my ManagedBean. I can't create one variable for each Question, because this is dynamic and I don't know the amount of questions in design-time.
SOLVED:
I used a Map in RadioButton, see:
<h:selectOneRadio
value="#{cursandoMB.alternativasEscolhidas[questaoCurso]}" converter="entityConverter" layout="pageDirection">
<f:selectItems
value="#{questaoCurso.questao.alternativasPreenchidas}" var="c"
itemValue="#{c}" itemLabel="#{c.texto}" />
</h:selectOneRadio>