因此,这与经常被问到的“如何将消息呈现到多个表单”相反。我在一页上有两个表单,在一个表单中验证后,摘要错误(如果验证失败)显示在提交按钮下方的两个表单上。如果代码成功发送所需的电子邮件,则确认消息也会以两种形式显示。它们应该只显示在提交的表单中。inputTexts 下面的消息可以正常工作。我究竟做错了什么?
<p:panel>
<h:form id="id_rememberUserNameForm" prependId="false">
<td>
...
<p:inputText
id="id_existingEmailAddress"
styleClass="registerinputtext width_20em"
size="20"
maxlength="60"
value="#{credentialsManagementBean.emailAddress}"
validator="#{multivalidator.validateEmailExists}" >
<f:ajax event="blur" render="id_noSuchEmailError" />
</p:inputText>
</td>
</tr>
<!-- validation error handling +++++++++++++++++ -->
<tr class="errorMessage min_height_1p5em">
<td colspan="2" >
<h:message for="id_existingEmailAddress"
id="id_noSuchEmailError"
showDetail="false"
showSummary="true"/>
</td>
</tr>
</table>
<p:commandButton id="id_remindUsernameButton"
value="Retrieve Username"
action="#{credentialsManagementBean.rememberUsername}" >
<f:ajax execute="id_rememberUserNameForm" render="id_UserReminderMessage" />
</p:commandButton>
<p:messages id="id_UserReminderMessage"
showSummary="false"
showDetail="true"
autoUpdate="true" />
</h:form>
</p:panel>
<!-- next form +++++++++++++++++ -->
<p:panel>
<h:form id="id_resetPasswordForm" prependId="false">
...
<p:inputText
id="id_existingUsername"
styleClass="registerinputtext width_20em"
size="20"
maxlength="20"
value="#{credentialsManagementBean.username}"
validator="#{multivalidator.validateUsernameExists}">
<f:ajax event="blur" render="id_noSuchUserError" />
</p:inputText>
</td>
</tr>
<!-- validation error handling +++++++++++++++++ -->
<tr class="errorMessage min_height_1p5em">
<td colspan="2" >
<h:message for="id_existingUsername"
id="id_noSuchUserError"
showDetail="true"
showSummary="false"/>
</td>
</tr>
</table>
<p:commandButton id="id_resetPasswordButton"
value="Retrieve Username"
action="#{credentialsManagementBean.resetPassword}" >
<f:ajax execute="id_resetPasswordForm" render="id_pwResetMessage" />
</p:commandButton>
<p:messages id="id_pwResetMessage"
showSummary="true"
showDetail="false"
autoUpdate="true" />
</h:form>
</p:panel>