0 Replies Latest reply on May 6, 2009 8:24 AM by dragos cernahoschi

    suggestionbox and inputText validation problem

    dragos cernahoschi Newbie

      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" />
       <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>

      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" />

      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>
      <span class="value #{invalid?'errors':''}">
      <span class="error">
       <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
       <s:message styleClass="errors"/>

      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?