0

I am running JSF2.0 with Java 6 code on JBOSS 7.1.0.Final. Here is the code for my page:

    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.org/schema/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:a4j="http://richfaces.org/a4j"
    template="layout/template.xhtml">

    <ui:define name="body">

        <h:form id="quizform">
            <rich:panel>
                <f:facet name="header">Quiz Details</f:facet>

                <a4j:repeat value="#{quizHome.mcqs}" var="_mcq" rowKeyVar="idx">
                    <s:decorate template="layout/display.xhtml">
                        <h:outputText value="#{idx+1}.#{_mcq.questionText}"/>
                        <h:selectOneRadio id="optionId-#{idx}" immediate="true" value="#{answerBean.optionId}" valueChangeListener="#{answerBean.selectAnswerLsnr}">
                            <s:selectItems value="#{_mcq.mcqOptions}" var="opt" label="#{opt.optionText}" itemValue="#{opt.id}" />
                         </h:selectOneRadio>
                    </s:decorate>
                </a4j:repeat>   

                <div style="clear:both"/>
            </rich:panel>

            <div class="actionButtons">
                <h:commandButton value="Submit Response" action="#{answerBean.findUserAnswer}" />
                <h:commandButton value="Reset" type="reset" />
                <s:button view="/StartQuiz.xhtml" id="startquiz" value="Restart Quiz"/>
            </div>
        </h:form>
    </ui:define>

</ui:composition>

The page renders with correct values from the database. But, on submitting the form, I get the following message in the browser:

value is not valid.

What am I doing wrong? Thanks for your suggestions.

aquila
  • 1
  • 1
  • possible duplicate of [Validation Error: Value is not valid](http://stackoverflow.com/a/9069660) – BalusC Mar 16 '13 at 11:18
  • Thanks for your answer. But, I'm still not closer to the solution. Further debugging shows that, the "not valid value" error happens for some of the questions, not all. And these questions are random. – aquila Mar 16 '13 at 13:20
  • Your answer helped me get to the root cause. The Java bean was being created again on submit, and retrieving data from DB again, thus, changing the order of the questions on the page. Therefore, the options selected by the users became invalid. Changing the scope to @ViewScoped solved the issue. – aquila Mar 23 '13 at 03:57

0 Answers0