« Return to Thread: selectOneRadio validation error
Have you looked at layout=spread and see
if that would help.
From: Scott Carter
[mailto:carterdevlists@...]
Sent: Thursday, June 25, 2009 5:15
PM
To: users@...
Subject: selectOneRadio validation
error
I have a jsf page which has a series of questions on it, each with
radio select for the answers. Each of the questions uses the same set of
answers ( Agree . Disagree, Neutral ). Since so many of the possible
answer sets repeat themselves I just put a method in the backing bean that
returns an array of SelectItem with the choices in it.
This approach only works if the user only answers one question. If more
than one question is answered (the user selects a radio button for more than
one question) then a validation error occurs. Each of the
<h:selectOneRadio> tags has a unique id. Also each of the
<f:selectItem> tags have a unique id, even though they call back to the
same backing method for the choices. In the backing bean method a new
array is created and returned each time for the choices. I even tested
creating a new method that returns an array of of SelectItem for the choices
and had exactly the same issue.
If I change the code and put the <f:selectItem> tags directly inline in
the code instead of calling the backing bean for an array of selectItems , then
everything works like it should. I am very lost as to why I can not use
the <f:selectItems> functionality more than once in a page. Here is
a piece of the code:
<tr><td><h:outputText value="#{assessment.currentQuestionText}"
/></td></tr>
<tr><td><h:selectOneRadio
id="q3answers" value="#{assessment.q3}">
<f:selectItems id="q3list"
value="#{assessment.currentQuestionAnswers}"/>
</h:selectOneRadio>
<br>
</td>
</tr>
<tr><td><h:outputText
value="#{assessment.currentQuestionText}" /></td></tr>
<tr><td><h:selectOneRadio
id="q4answers" value="#{assessment.q4}">
<f:selectItems id="q4list"
value="#{assessment.currentQuestionAnswers}"/>
</h:selectOneRadio>
<br>
</td>
</tr>
You can see that each time I want a list of answers I call the
currentQuestionAnswers method of the backing bean. The page displays
correctly, and like stated above, the user can select an answer to one of the
questions, but if the user answers both questions there is a validation error
everytime. Any ideas? Help is greatly appreciated!
- Scott
« Return to Thread: selectOneRadio validation error
| Free embeddable forum powered by Nabble | Forum Help |