0 Replies Latest reply on Nov 28, 2011 3:27 PM by Brian Chow

    rich:Autocomplete displaying label or erasing on validation

    Brian Chow Newbie

      Hello all, I did some searching on google and the forums but havnt really come up with much.

       

      I'm currently using an rich:autocomplete to select an object from a SelectItem list.

       

      However, on validation fail anywhere else on the form, the display name changes from the proper name to the id of the object. Then after that, on form submit after fixing the previous validation fail, the autocomplete looks like it has a value but does not and triggers the requiredMessage. Has any one else encountered this issue before or have a clue on how to proceed?

       

       

      1. For instance if I select "Test Agency" from my AutoComplete List

      1.jpg

       

       

       

      2. Then I submit my form with nothing else filled in (to force validation fail)

       

      Such as:

      2b.jpg

      The Autocomplete Box now shows the ID instead of the name, "Test Agency"

       

      2a.jpg

       

       

       

       

      3. Now if I fill in the First Name input box and resubmit, I get validation error on my AutoComplete Box saying no agency is selected

      3a.jpg

      3b.jpg

       

       

       

       

      AutoComplete on jsf page:

                  <a4j:jsFunction name="blurFunction" execute="companySelect" render="wrapper"/>
                  <rich:autocomplete label="Company Select"
                      converter="autoCompleteConverter" 
                      value="#{userBean.agency}" 
                      id="companySelect" 
                      defaultLabel="Start typing to find account"
                      autocompleteMethod="#{userEditBean.searchRichAgencyItems}"
                      var="Agency"
                      fetchValue="#{Agency.label}"
                      minChars="2"
                      required="true" requiredMessage="Please select an agency"
                      onblur="blurFunction()"
                      >
                       <h:outputText value="#{Agency.label}"/>
                       <f:attribute name="beanClass" value="com.dnc.Agency" />
                       <f:attribute name="selectItemList" value="#{userBean.AgencyList}" />
                       <a4j:ajax event="selectitem" render="wrapper" rerender="wrapper" />
                    </rich:autocomplete>
      
      

       

       

      autocompleteMethod:

       

      public List<SelectItem> searchRichAgencyItems(String filter) {
           // Searches a List<SelectItem> of agencys processed with the filter and returns the associated SelectItems
      }
      

       

       

       

      autoCompleteConverter:

       

      public class AutoCompleteConverter extends SelectItemConverter {
           protected Object getMvAgency(UIComponent uiComponent, String value, Object result) {
                // Finds the correct object, and returns it
           }
      }
      

       

       

      Thanks in advanced, let me know if something else needs to be posted inaddition to.