我有一个 jsf 表单,其中包含两个输入和两个验证,当我填写其中一个输入(例如 firstName)然后单击提交时,验证被触发。当我单击新建时,它应该更新整个表单,但它不会清除 firstNamme 输入,我必须通过单击 new 来提及 userManagement bean 中的 clearList 函数被触发。如果我填写名字输入然后单击新建而不单击提交,它将清除名字输入。
<p:layout id="manageServiceLayout">
<p:panel header="#{i18n['add_new_user']}"
style="text-align:right; margin:10px">
<p:messages />
<h:panelGrid columns="3" class="mar">
<h:outputText value="* #{i18n['user_firstName']}: " />
<p:inputText id="firstName" binding="#{firstName}"
value="#{userManagement.user.firstName}" required="true"
requiredMessage="# {i18n['user_firstName_required']}" />
<h:outputText value="* #{i18n['user_lastName']}: " />
<p:inputText id="lastName" value="#{userManagement.user.lastName}"
required="true"
requiredMessage="#{i18n['user_lastName_required']}" />
</h:panelGrid>
</p:panel>
<p:commandButton value="#{i18n['submit']}" update=":addUserform" id="submit">
<f:actionListener
binding="#{userManagement.updateActionEditOrAddUser}" />
<f:actionListener binding="#{tableUserBean.updateAction}" />
</p:commandButton>
<p:commandButton value="#{i18n['delete']}"
rendered="#{userManagement.update}"
actionListener="#{userManagement.deleteUser}"
action="#{tableUserBean.updateTableUserBean}" update=":addUserform">
</p:commandButton>
<p:commandButton value="#{i18n['new']}" process="@this" id="new"
action="#{userManagement.clearList}"
partialSubmit="true"
update=":addUserform">
</p:commandButton>
</p:layout>
</h:form>
//////function in userManagement bean
public void clearList() {
try {
User user = new User();
} catch (SystemException e) {
e.printStackTrace();
}
}