![]()
I'm currently working on a project which uses the Mojarra 2.0.3 JSF reference implementation. I encounterd a really strange bug today ...
Imagine you have the following form (code entered in pseudocode, just to make it compact and clear):
<h:form> <div> <h:inputText id="field1" value="#{Bean.singleField.value}" required="true"/> </div> <div> <ui:repeat value="#{Bean.listOfFields}" var="field"> <h:inputText value="#{field.value}"/> </ui:repeat> </div> <h:commandButton value="Submit" type="submit" action="#{Bean.doAction} /> </h:form>
Scenario:
Now, when you don't provide a value in field1 (you do provide values in the other fields) and you submit the form, validation will fail (because of the required attribute).
The problem:
When the form rerenders, all values in the input fields inside the ui:repeat tag are gone.
The solution
After some research, we found out we stumbled into the following bug: http://java.net/jira/browse/JAVASERVERFACES-1807. So we should upgrade our JSF implementation (which isn't an option for the moment). Luckily, we are using Richfaces in our project so we could replace the ui:repeat tag by the A4J equivalent: aj4:repeat.
Add new comment