1 Reply Latest reply on Jun 27, 2007 12:58 PM by Sergey Smirnov

    JSF Validation attribute required="true" doesn't work in Aja

    Bansilal Haudakari Newbie

      Here is the snippet where Attribute <required="true"> doesn't work using Ajax4Jsf 1.0.4, Facelets 1.1.12, MyFaces 1.1.14

      <h:form id="manufacturer">

      <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
      <h:outputText value="Manufacturer" />
      <h:selectOneMenu id="manufList" value="#{manufacturerBean.selectedManufacturer}" styleClass="dropdown">
      <f:selectItem itemLabel="New" itemValue="New" />
      <f:selectItems value="#{manufacturerBean.manufacturerList}" />
      <a4j:support action="#{manufacturerBean.loadManufacturerDetails}" event="onchange" reRender="t2,t3,t4,t5" />



      <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
      <h:outputText value="Name" />
      <h:inputText id="t3" value="#{manufacturerBean.name}" required="true" />
      <h:message id="nameError" for="t3" style="color: red; text-decoration: overline" />

      required="true" breaks the functionality of other dropdown i.e. h:selectOneMenu onchange event will never fire in case i pick a value from the drop down

      Any pointers/suggestions will be highly appreciated

        • 1. Re: JSF Validation attribute required=
          Sergey Smirnov Master

          it works like it must work in JSF - the form is not processed successfully and model is not updated if validation process for one (or several fields) is failed.

          First, <h:message id="nameError" for="t3" style="color: red; text-decoration: overline" /> does not make sense for Ajax. You have to have to wrap it with <a4j:outputPanel ajaxRendered="ajax" />

          also, wrap up your h:selectOneMenu with <a4j:region>