gpt4 book ai didi

jsf - 警告面消息已入队,但可能尚未显示

转载 作者:行者123 更新时间:2023-12-04 12:51:22 27 4
gpt4 key购买 nike

我有一个带有输入验证的表单,如下所示:

<h:form id="insurance-form" rendered = "#{(param['insSaved']=='editable')}">
<div id="insurance-info">
<ul id="form-labels" style="text-align:left;">
<li>Insurance Company&nbsp;</li>
<li>Policy Number&nbsp;</li>
<li>Coverage Amount&nbsp;</li>
<li>Agent's Phone Number&nbsp;</li>
<li>Agent's Email&nbsp;</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)]

请建议如何解决这个问题。

最佳答案

消息未显示,因为在回发时根本没有呈现整个表单。您指示表单仅在 insSaved 的请求参数时呈现值为 editable .但是,在提交按钮中,它已更改为 saved ,因此表单基本上不会在回发时呈现,因此也不会呈现随附的消息。鉴于代码的设置方式,这是完全预期的行为。

如果无论如何你想在回发验证错误的情况下显示表单,那么你需要改变它的 rendered相应地属性。代替

<h:form id="insurance-form" rendered="#{(param['insSaved']=='editable')}">

经过
<h:form id="insurance-form" rendered="#{(facesContext.postback and facesContext.validationFailed) or (param['insSaved'] == 'editable')}">

关于jsf - 警告面消息已入队,但可能尚未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13128266/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com