我有一個用於註冊表單的代碼。有一些字段和<p:commandButton>.
類型的提交按鈕現在,當我提交按鈕時,它將在呈現輸入字段值的表單下顯示一個數據表。 我想在表單提交後清除輸入文本字段。但價值依然存在。 如何清除表單文本字段的值?PrimeFaces在提交表格時清除文本字段
<p:panel header="Registration Form" closable="true" closeSpeed="100" toggleable="true" toggleSpeed="100" toggleOrientation="vertical">
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel value="*First Name"/>
<p:inputText id="firstname" value="#{registrationDetails.firstName}" required="true" label="First Name" requiredMessage="First Name required!"/>
<p:outputLabel value="*Last Name"/>
<p:inputText id="lastname" value="#{registrationDetails.lastName}" required="true" label="Last Name" requiredMessage="Last Name required!"/>
<p:outputLabel value="Location"/>
<p:selectOneMenu id="location" value="#{registrationDetails.location}">
<f:selectItem itemLabel="Select Location" itemValue=""/>
<f:selectItems value="#{registrationDetails.locations}"/>
</p:selectOneMenu>
<p:outputLabel id="email" value="*Email"/>
<p:inputText value="#{registrationDetails.email}" required="true" label="Email" requiredMessage="Email address required!"/>
<p:outputLabel value="*Contact Number"/>
<p:inputText id="contactNumber" value="#{registrationDetails.contactNumber}" autocomplete="false" maxlength="10" required="true" label="Contact Number" requiredMessage="Contact Number required!"/>
<p:outputLabel value="Address"/>
<p:inputTextarea value="#{registrationDetails.address}"/>
</h:panelGrid>
<p:commandButton value="Submit" actionListener="#{registrationDetails.formSubmit}" id="buttonSubmit"
update="form:msg form:regDetailPanel form:regData" ajax="true">
<f:attribute name="fname" value="#{registrationDetails.firstName}"/>
<f:attribute name="lname" value="#{registrationDetails.lastName}"/>
<f:attribute name="loc" value="#{registrationDetails.location}"/>
<f:attribute name="email" value="#{registrationDetails.email}"/>
<f:attribute name="contact" value="#{registrationDetails.contactNumber}"/>
<f:attribute name="address" value="#{registrationDetails.address}"/>
<p:ajax event="click" immediate="true" update="form:regDetailPanel form:regData"/>
</p:commandButton>
但是在'formSubmit'方法中,我得到輸入字段的值來創建要在數據表中呈現的列表.. :( – NDeveloper
@NGH您可以清除方法末尾的值(創建列表後在數據表中呈現) – dijkstra
謝謝..我做到了。:) – NDeveloper