How can I apply p:resetInput or p:ajax resetValue =“true” for p:dataList?

雨燕双飞 提交于 2019-12-08 10:11:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!