问题
All we know the problems of validation failed in JSF (take a look in here). Primefaces seems to resolve the problem with p:resetInput or p:ajax resetValue ="true".
Now I face another problem when I tried to use this way for p:dataList. The validation now work's really crazy, the value that was submitted before is back after validation fail. So, can anyone give me a solution? Thanks a bunch.
More info: I tried update panel, dataLists, even every component inside, but it still doesn't work.
Here is the code.
<p:panel id="panel" header="Form" style="margin-bottom:10px;">
<p:messages id="messages" />
<p:dataList value="#{bean.cars}" var="car">
<h:panelGrid columns="3" cellpadding="5">
<p:outputLabel for="text1" value="Text 1:" />
<p:inputText id="text1" value="#{car.text1}" required="true" >
<f:validateLength minimum="2" />
</p:inputText>
<p:outputLabel for="text2" value="Text 2:" />
<p:inputText id="text2" value="#{car.text2}" required="true"/>
</h:panelGrid>
</p:dataList>
<p:commandButton value="Add" process="panel" update="panel" actionListener="#{bean.addNewCar}" style="margin-right:20px;" >
<p:ajax update="panel" resetValues="true" />
</p:commandButton>
</p:panel>
来源:https://stackoverflow.com/questions/51895400/how-can-i-apply-presetinput-or-pajax-resetvalue-true-for-pdatalist