JSF ui:repeat and f:ajax giving wrong value for h:inputText after rerender.
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-06-14T06:10:43Z
Indexed on
2010/06/14
6:12 UTC
Read the original article
Hit count: 624
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.
© Stack Overflow or respective owner