Hello,
I've got a dataList bound to a list of values in the backing bean as such:
<x:dataList id="questionList" layout="simple"
value="#{assessmentHandler.currentPage.questions}" var="question">
<h:outputText value="#{question.questionNo}.
#{question.text}" />
<f:verbatim><br /></f:verbatim>
<h:selectOneRadio id="choices" required="true"
value="#{assessmentHandler.responses[question.questionNo - 1].score}">
<f:selectItem id="oftenChoice"
itemValue="#{assessmentHandler.oftenScore}"
itemLabel="#{labels.oftenLabel}" />
<f:selectItem id="sometimesChoice"
itemValue="#{assessmentHandler.sometimesScore}"
itemLabel="#{labels.sometimesLabel}" />
<f:selectItem id="seldomChoice"
itemValue="#{assessmentHandler.seldomScore}"
itemLabel="#{labels.seldomLabel}" />
</h:selectOneRadio>
</x:dataList>
The assessmentHandler has the method getResponses() which returns a List
of Response objects. The Response objects has a getter/setter for the
score attribute. However, when I click the command button to advance to
the next page or to finish the questioning the Response objects score
values in the backing list is not updated with the value of the select
item. The required="true" attribute also seems to be ignored, because I
can safely advance without any errors. Is this not the right way to do
something like this?
I've looked at the list and the only alternative is to use Bruno
Aranda's valueChangeListener solution from the "is it possible to edit
dynamic Tabular data?" thread. But, as was stated in that thread, it
seems like the way I'm doing it should work to update the data model. I
don't need to implement a setResponses() method do I? The setScore()
method on the actual Response object should be enough, shouldn't it be?
I'm sure I don't need to use the preserveDataModel attribute or an
<x:saveState /> element. So what's missing?
Thanks,
Rich