Ajax form item validation required message not rendering

387 views Asked by At

I am validating the inputted items of the form when form is submitted through AJAX but the form is not rendering the required message in the h:message section. By full post back method validation method works fine but in AJAX submission method the required message doesn't render.

Here is the code:

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

There are 0 answers