我有一个带有输入验证的表单,如下所示:
<h:form id="insurance-form" rendered = "#{(param['insSaved']=='editable')}">
<div id="insurance-info">
<ul id="form-labels" style="text-align:left;">
<li>Insurance Company </li>
<li>Policy Number </li>
<li>Coverage Amount </li>
<li>Agent's Phone Number </li>
<li>Agent's Email </li>
</ul>
<ul>
<li>
<h:inputText value="#{residenceBeans.insuranceCompany}" id="insurance-company" required="true" requiredMessage="company is required"/>
<h:message for="insurance-company" styleClass="validation-error-msg insuarnce-validation"/>
</li>
<li>
<h:inputText value="#{residenceBeans.policyNumber}" id="insurance-policy" required="true" requiredMessage="number is required"/>
<h:message for="insurance-policy" styleClass="validation-error-msg insuarnce-validation"/>
</li>
<li>
<h:inputText value="#{residenceBeans.coverageAmount}" id="insurance-amount" required="true" requiredMessage="coverage amount is required"/>
<h:message for="insurance-amount" styleClass="validation-error-msg insuarnce-validation"/>
</li>
<li>
<h:inputText value="#{residenceBeans.agentPhone}" id="insurance-phone" required="true" requiredMessage="phone is required"/>
<h:message for="insurance-phone" styleClass="validation-error-msg insuarnce-validation"/>
</li>
<li>
<h:inputText value="#{residenceBeans.agentMail}" id="insurance-mail" required="true" requiredMessage="email is required">
<f:validator validatorId="emailValidator"/>
</h:inputText>
<h:message for="insurance-mail" styleClass="validation-error-msg insuarnce-validation"/>
</li>
</ul>
<h:commandLink value="SAVE POLICY INFORMATION" action="#{residenceBeans.saveInsuranceInfo}" styleClass="insurance-link-container">
<f:param name="insSaved" value="saved"/>
</h:commandLink>
</div>
</h:form>
当将字段留空并提交表单时,我希望显示验证消息,但我收到以下警告:
21:20:47,671 INFO [javax.enterprise.resource.webcontainer.jsf.renderkit] (http--127.0.0.1-8080-3) WARNING: FacesMessage(s) have been enqueued, but may not have been displayed
sourceId=insurance-form:insurance-company[severity=(ERROR 2), summary=(company is required), detail=(company is required)]
sourceId=insurance-form:insurance-policy[severity=(ERROR 2), summary=(number is required), detail=(number is required)]
sourceId=insurance-form:insurance-amount[severity=(ERROR 2), summary=(coverage amount is required), detail=(coverage amount is required)]
sourceId=insurance-form:insurance-phone[severity=(ERROR 2), summary=(phone is required), detail=(phone is required)]
sourceId=insurance-form:insurance-mail[severity=(ERROR 2), summary=(email is required), detail=(email is required)]
请告知如何解决。