JSF ui:repeat and f:ajax giving wrong value for h:inputText after rerender.
- by Andrew
I have a list of questions and I can display them ok using a ui:repeat, but after clicking the Edit button the rerendered inputText is given the wrong question.id. For some reason, if you click Edit on the first item, the inputText value assigned is that of the second item in the list, even though other outputs (other than the h:inputText element) are correct.
<h:form id="questionnaireForm">
<ui:repeat value="#{ProjectManager.currentProject.preQuestions}" var="question" varStatus="current"
id="preQuestionsRepeat">
<div>
<ui:fragment rendered="#{!question.editing}">
<f:ajax render="@form">
<p>#{question.id} #{question.questionText}</p>
<h:inputText value="#{question.id}"/>
<h:commandLink styleClass="link"
action="#{question.setEditing}"
value="Edit">
</h:commandLink>
</f:ajax>
</ui:fragment>
</div>
<div>
<ui:fragment rendered="#{question.editing}">
<f:ajax render="@form">
<p>#{question.id} #{question.questionText}</p>
<h:inputText value="#{question.id}"/>
</f:ajax>
</ui:fragment>
</div>
</ui:repeat>
</h:form>
Obviously I don't really want to edit the id. I just want the correct question.something to show up in my inputText :-)
Perhaps I'm not using correctly? It seems fine according to my reading so far.
Many thanks for your assistance.