Jsf Ajax表单项验证所需消息未呈现

Jsf Ajax表单项验证所需消息未呈现,jsf,validationmessage,ajax-update,Jsf,Validationmessage,Ajax Update,当表单通过AJAX提交时,我正在验证表单的输入项,但是表单没有在h:message部分呈现所需的消息。通过完全回发方法,验证方法可以很好地工作,但在AJAX提交方法中,所需的消息不会呈现 代码如下: item.xhtml <h:form class="form-signin" id="registrationform" enctype="multipart/form-data"> <h:panelGroup id="panel" border="0" cellpaddi

当表单通过AJAX提交时,我正在验证表单的输入项,但是表单没有在
h:message
部分呈现所需的消息。通过完全回发方法,验证方法可以很好地工作,但在AJAX提交方法中,所需的消息不会呈现

代码如下:

item.xhtml

<h:form class="form-signin" id="registrationform" enctype="multipart/form-data">
    <h:panelGroup id="panel" border="0" cellpadding="0" cellspacing="10" styleClass=" labelText">
        <f:facet name="header">
            <h:messages id="message" style="color:red;margin:8px;" globalOnly="true" />
        </f:facet>
    </h:panelGroup>
    <div class="section-title">
        <div class="title">Item Description</div>
    </div>
    <h:panelGrid columns="6">
        <h:outputLabel for="goodName" value="Names of good *" styleClass="labelforItems" />
        <h:outputLabel for="quantity" value="Quantity *" styleClass="labelforItems" />
        <h:inputText id="quantity" style="#{ component.valid ? 'border-color:#ccc;' : 'border-color:red;'}" value="#{registrationBean.quantity}" styleClass="form-control input-adjust quantity" required="true" requiredMessage="Package quantity is required." />
        <h:outputLabel for="hscode" value="HS Code*" styleClass="labelforItems" />
        <h:inputText id="hscode" value="#{registrationBean.hscode}" styleClass="form-control input-adjust hscode" required="true" requiredMessage="HS Code is required" />
        <h:outputLabel for="goodsDescription" value="Description *" styleClass="labelforItems" />
        <h:inputTextarea id="goodsDescription" value="#{registrationBean.descriptions}" style="#{ component.valid ? 'border-color:#ccc;' : 'border-color:red;'}" required="true" requiredMessage="Goods description is required." styleClass="form-control textareawh goodsDescription" />
        <h:commandLink value="Add" id="addItem" action="#{registrationBean.addItemAction}" onclick="pkgDiv()" styleClass="btn btn-primary">
            <f:ajax execute="goodName quantity brand model hscode goodsDescription" render=":registrationform:panel"  />
        </h:commandLink>
        <h:outputLabel />
        <h:outputLabel />
        <h:outputLabel />
        <h:outputLabel />
    </h:panelGrid>
</h:form>

项目说明

我正在使用JSF2.2版本。我已经从代码中删除了表单中的文件字段,因此我使用了enctype=“multipart/form data”。我使用的是Mojarra 2.2版本,我认为最新版本在post中提供了版本,而不是注释
globalOnly=“true”
将仅显示未连接组件的消息,您的消息用于输入,因此请尝试删除此属性。