Input fields lose value in table using immediate=true
mocha Mar 27, 2008 2:17 PMMy understanding is that this is a limitation of JSF, but since Seam fixes so many JSF limitations, I am hoping Seam has an answer for this also.
I have a web page where the user can add new items to a list and edit values of existing items in the list. This is implemented in a facelets view as follows:
<a:outputPanel id="questionPanel"> <h:dataTable value="#{questionnaire.questions}" var="question"> <h:column> <f:facet name="header">Question Text</f:facet> <h:inputText id="description" value="#{question.description}" required="true"/> </h:column> <h:column> <a:commandLink value="delete" reRender="questionPanel" action="#{questionnaire.removeQuestion(question)}" immediate=true" /> </h:column> </h:dataTable> </a:outputPanel> <a:commandButton value="add a question" reRender="questionPanel" action="#{questionnaireController.removeQuestion(question)}" immediate=true" /> <h:commandButton value="save" action="#{questionnaireController.save}"/>
I have specified immediate="true" on the ajax commands because the user should be able to add to the list without being stopped by incomplete fields elsewhere on the page. However, this causes an issue in that the values entered into input fields in the table are lost when the user clicks add or delete. I can confirm this issue only applies to the fields in the table as I have a couple of input fields outside of the table which are retained when the page is rendered. BTW, the behaviour is the same when using ui:repeat instead of h:dataTable.
The behaviour with bypassUpdates="true" on the ajax commands is better, but results in error messages showing for the incomplete fields as the user adds or deletes items. I'd prefer this validation to just kick in when the user hits save.
So, any neat solutions out there? the immediate="true" seems intuitively correct (i.e. don't bind inputs to model until save), but I need it to work inside the table. The discussion I linked to at the start of this post talks about subforms which appears to be part of the adf faces library. Perhaps seam or richfaces provides something similar?
Thanks in advance.
Willy.