Ajax表单项验证需要消息不呈现

时间:2016-02-24 06:56:33

标签: 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" 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>

0 个答案:

没有答案