0
我有一個問題列表,我可以使用ui:repeat來顯示它們,但是單擊Edit按鈕後,重新輸入inputText被賦予錯誤的問題。出於某種原因,如果在第一項上單擊編輯,則分配的inputText值是列表中第二項的值,即使其他輸出(除h:inputText元素之外)都是正確的。JSF ui:repeat和f:ajax在給出h:inputText後給出錯誤的值
<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>
顯然我不是真的想編輯id。我只是想要正確的問題。我的輸入文本中顯示的東西:-)
也許我沒有正確使用?到目前爲止,根據我的閱讀,這似乎很好。
非常感謝您的協助。
謝謝你這個布賴恩。我嘗試了你聽起來很棒的建議,但不幸的是它沒有任何區別,所以我們重新設計了整個頁面來使用jQuery和一個servlet代替;-) – Andrew 2010-07-13 05:19:45