Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-1441

Autocompleter autofills textfield with unexpected value

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.1.5
    • Component/s: XHR/dhtml/Ajax
    • Labels:
      None
    • Environment:
      Tapestry 4.1.2 snapshot from 5-3, WinXP, Firefox 2

      Description

      After you begin typing into an Autocompleter, the dropdown appears with possible values and the textfield attempts to autofill itself. I would assume it is supposed to autofill with the first available value. The problem is the text it tries to autofill with is not right if the possible values don't start with the value entered by the user (a contains search).

      As an example, say I have an autocompleter with the values "01 blah", "02 blah", "03 blah", "04 blah", and "05 blah". I type "bla" into the textfield and wait for the dropdown to appear. When the dropdown appears, all of the possible values appear as expected, but the textfield now says "blablah". I would not expect "blah" to get appended to the "bla" I typed in as this is not a valid choice.

      Either the textfield should autofill with a valid value, or it shouldn't autofill at all, like the Tacos autocompleter. (I would prefer the latter.)

      Here is some code to replicate the example:

      .html:
      <form jwcid="@Form">
      <span jwcid="autocompleteTest@Autocompleter" value="ognl:curValue" model="ognl:model" />
      </form>

      .java:
      public abstract String getCurValue();

      public IAutocompleteModel getModel()
      {
      final List<String> values = Arrays.asList("01 blah", "02 blah", "03 blah", "04 blah", "05 blah");

      return new IAutocompleteModel()
      {
      public String getLabelFor(Object value)

      { return (String) value; }

      public List getValues(String filter)
      {
      List<String> result = new ArrayList<String>();

      for (String val : values)
      {
      if (val.contains(filter))

      { result.add(val); }

      }
      return result;
      }

      public Object getPrimaryKey(Object value)

      { return values.indexOf(value); }

      public Object getValue(Object primaryKey)

      { return values.get((Integer) primaryKey); }

      };
      }

        Attachments

          Activity

            People

            • Assignee:
              andyhot Andreas Andreou
              Reporter:
              dotteben Ben Dotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: