Using variable attribute validator in ui: repeat

I am using the com.sun.facesversion 2.1.18. In my application, I have a dynamic list of questions. I use <ui:repeat>to render each question. Depending on the type of question, I present the type of input component and the validation. In case of a question about the range of numbers I use <h:inputText>with <f:validateLongRange>.

The problem I am facing is that the attributes minimumand maximumin are <f:validateLongRange>always set to the minimum and maximum value of the first question. Thus, when you use the validator for any other, the first question fails. Is this supposed to happen? Is there a way to get validation working with dynamically generated components? I hope this can be resolved without going to <c:forEach>.

Code snippet:

<ui:repeat value="#{questionnaire.questionsCollection}"
           var="question">
  ..
  <h:inputText value="..">
    <f:validateLongRange minimum="#{question.minimumValue}"
                         maximum="#{question.maximumValue}"/>
  </h:inputText>
  ..
</ui:repeat>

I deduced #{question.minimumValue}and #{question.maximumValue}, and they have the correct values ​​for my question.

+5
source share
1 answer

/ . -, <f:validateXxx>, . , , , <ui:repeat>. , , , JSTL <c:forEach>. : JSTL JSF2 Facelets... ?

, : ? . OmniFaces <o:validator> validator <o:validator> ,

<f:validateLongRange minimum="#{question.minimumValue}"
                     maximum="#{question.maximumValue}" />

<o:validator validatorId="javax.faces.LongRange" 
             minimum="#{question.minimumValue}"
             maximum="#{question.maximumValue}" />

.

:

+8

All Articles