1 Reply Latest reply on May 7, 2009 8:28 PM by dcernahoschi

    suggestionbox and inputText validation problem

    dcernahoschi

      I have the following suggestionbox that supports an inputText:


      
      
      <h:form id="clientForm">
      
      <s:decorate id="clientNameDecoration" template="layout/edit.xhtml">
           <ui:define name="label"><h:outputText value="#{messages['client.clientName']}"/>:</ui:define>
           <h:inputText id="clientName" value="#{invoicing.client.clientName}" required="true" size="30" tabindex="10">
                   <a:support event="onblur" ajaxSingle="true" reRender="clientNameDecoration" />
           </h:inputText>          
           <rich:suggestionbox for="clientName" ajaxSingle="true" suggestionAction="#{invoicing.filterClientsByName}" var="client">
                <a:support event="onselect" action="#{invoicing.fillClient(client.id)}" reRender="clientForm" focus="next"/>
                <h:column><h:outputText value="#{client.clientName}"/></h:column>
            </rich:suggestionbox>
      </s:decorate>
      
      </h:form>
      
      



      The onselect method fillClient fills the #{invoicing.client} with selected value from the suggestionbox.


      The <h:form> contains more fields like this:


      
      <s:decorate id="clientCuiDecoration" template="layout/edit.xhtml">
           <ui:define name="label"><h:outputText value="#{messages['client.cui']}"/>:</ui:define>
           <h:inputText id="clientCui" value="#{invoicing.client.cui}" required="true" size="30" tabindex="20">
                <a:support event="onblur" ajaxSingle="true" reRender="clientCuiDecoration" />
           </h:inputText>
      </s:decorate>
      
      



      Scenario with the problem:


      1. An invalid input is entered in one of the form fields and the hibernate validation kicks in. The field is marked as invalid on the user interface.
      2. The user selects a value from the suggestionbox and now the form is filled with valid object data, including the previously invalid inputText.
      3. The form is rendered according to the onselect event, the validation message disapears, but the inputText remains marked as invalid (with red surroundings ...)


      The /edit.xhtml template is the following:


      <s:label styleClass="name #{invalid?'errors':''}">
          <ui:insert name="label"/>
          <s:span styleClass="required" rendered="#{required}">*</s:span>
      </s:label>
      
      <span class="value #{invalid?'errors':''}">
           <s:validateAll>
               <ui:insert/>
           </s:validateAll>
      </span>
      
      <span class="error">
           <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
           <s:message styleClass="errors"/>
      </span>
      




      The problem seems to be with the #{invalid} value in the edit.xhtml template that evaluates to true at the time the <h:form> is rerendered.


      Do I miss something?