2012-07-25 59 views
1

我想知道爲什麼,當我在inputTextarea中輸入某些內容時,不會更新輔助bean。 當我打印出結果時,它返回「」。 System.out.println(devoir.lstQuestions.get(0).getReponse());顯示「」;在jsf中設置集合屬性

<ui:repeat value="#{devoirController.devoir.lstQuestions}" var="question" /> 
    <h:inputTextarea value="#{question.reponse}" id="reponse"> 
    </h:inputTextarea> 
    </ui:repeat> 
+0

只是一個觀察 - 所有這些inputTextAreas將具有相同的ID。 ID = 「#{} question.reponse」? :-) – 8bitjunkie 2012-07-25 09:11:30

回答

1

爲了實現這一目標,#{devoirController}豆需要一個@ViewScoped豆和需要lstQuestions bean的構造函數或@PostConstruct方法進行預填充。 devoirlstQuestions的getter方法絕對不應包含除return propertyName;以外的任何其他代碼行。

+0

非常感謝BalusC爲此做出的迴應,它幫助我走出了困境。 – 2012-07-25 03:48:49