1 Reply Latest reply on Dec 14, 2015 12:15 PM by michpetrov

    rich:select with autocompleteList has validation error

    cm.tcomp

      environment: richfaces 4.5.5 final, jsf2.2.7, netbeans 8.0.2

       

      I'm trying to have users select from a autocomplete list to limit values a user may select. In the simplist test case,

       

      <rich:select
           autocompleteList="#{testBean.tmpArray}"
           mode="client"
           value="#{testBean.tmpstr}"
           >
      </rich:select>
      

       

      with String[] tmpArray (which was a dynamically generated list in my code), and String tmpstr. Trying to do any action results in a validation error from the component.

       

      In trying to figure out why the original code was failing, I ended up finding that the component is doing a vaidation even when there is no validation specified, and is not looking at the value attribute.

       

      It appears that this is related to jira  RF-14024 - rich:select - "autoCompleteMethod", "value" and "required" attributes not compatible?

      however, this is a more general case.

       

      In replacing the rich:select with rich:autocomplete, the component functions, but it allows the user to enter values that are not contained in the list.

       

      As the list could be large, I can't use a f:SelectItem in the rich:select component. Is there anyway to limit the values entered in the rich:autocomplete component, other than using a validator to ensure the input matches something from the list?

       

      Also, should the simpler case be entered into the jira also?

        • 1. Re: rich:select with autocompleteList has validation error
          michpetrov

          Why would you not be able to use selectItems?

           

          Anyway, if you want to make sure some condition is met you need validation. h:selectOneMenu (which rich:select is based on) does a validation over its children and the submitted value. Since you're not required to provide children for rich:select we create them for the validation but you need to set up @var.