ICEfaces
  1. ICEfaces
  2. ICE-9773

ace:autoCompleteEntry textChangeListener is not called on deletion of the last char

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 4.0
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      Glassfish 3.1.2.2
    • Assignee Priority:
      P2

      Description

      In the sample code below the textChangeListener is executed whenever the user types in oder deletes a char. If the deleted char was the last char, the field will be blanc, but in this case the textChangeListener is not executed.
      If the user types in "E", "i","n" and then presses delete key 3 times, the output is:
      INFO: textChanged(TextChangeEvent):E
      INFO: textChanged(TextChangeEvent):Ei
      INFO: textChanged(TextChangeEvent):Ein
      INFO: textChanged(TextChangeEvent):Ei
      INFO: textChanged(TextChangeEvent):E

      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:ace="http://www.icefaces.org/icefaces/components"
            xmlns:h="http://java.sun.com/jsf/html">
          <h:head></h:head>
          <h:body>
              <h:form>
                  <ace:autoCompleteEntry value="#{bean.value}"
                                         textChangeListener="#{bean.textChanged}"
                                         minChars="1">
                      <f:selectItems value="#{bean.items}"/>
                  </ace:autoCompleteEntry>
                  <h:inputText />
              </h:form>
          </h:body>
      </html>


      import java.util.List;

      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.SessionScoped;
      import javax.faces.model.SelectItem;

      import org.icefaces.ace.event.TextChangeEvent;

      @ManagedBean
      @SessionScoped
      public class Bean {

          private String value;
          private List<SelectItem> items = java.util.Arrays.asList(new SelectItem("Eins"), new SelectItem("Zwei"));

          public void textChanged(TextChangeEvent e) {
              System.out.println("textChanged(TextChangeEvent):" + e.getNewValue());
          }

          public String getValue() {
              return value;
          }

          public void setValue(String value) {
              this.value = value;
          }

          public List<SelectItem> getItems() {
              return items;
          }

          public void setItems(List<SelectItem> items) {
              this.items = items;
          }
      }

      This bug does not occur, if, for example, "minChars="1"" is omitted or is replaced by minChars="0".

      In Addition: A Listener should not be called when no action occured. I think, this interferes with the implicit autocomplete ajax-request. What if the developer does not want this textChangeListener be called on every key event?

        Activity

        Hide
        Ken Fyten added a comment -

        Confirmed to remain an issue using ICEfaces4 trunk r41836.

        Show
        Ken Fyten added a comment - Confirmed to remain an issue using ICEfaces4 trunk r41836.
        Hide
        Arturo Zambrano added a comment -

        I don't think this is a real issue. Things are just working the way they are meant to be. It's not only that textChangeListener is not called; none of the listeners are called (valueChangeListeners and the ajax valueChange and textChange listeners). This is so because the client-side code doesn't make a request to the server when there are less than the minimum number or characters specified (minChars) in the text field. As mentioned at the end of the JIRA description, this doesn't happen when minChars="0", which is the default value. There's nothing special about the last character either. Take for example the case where minChars="3" and you type 5 characters and then start to delete them one by one; in this case you won't see a request being made when you delete the third-to-last, second-to-last and last characters.

        If we only care about this specific scenario, when minChars="1". Then, we can extend the rule "there have to be at least

        {minChars} to make a request" and add "if a character is deleted, there had to be at least {minChars}

        to make a request".

        Show
        Arturo Zambrano added a comment - I don't think this is a real issue. Things are just working the way they are meant to be. It's not only that textChangeListener is not called; none of the listeners are called (valueChangeListeners and the ajax valueChange and textChange listeners). This is so because the client-side code doesn't make a request to the server when there are less than the minimum number or characters specified (minChars) in the text field. As mentioned at the end of the JIRA description, this doesn't happen when minChars="0", which is the default value. There's nothing special about the last character either. Take for example the case where minChars="3" and you type 5 characters and then start to delete them one by one; in this case you won't see a request being made when you delete the third-to-last, second-to-last and last characters. If we only care about this specific scenario, when minChars="1". Then, we can extend the rule "there have to be at least {minChars} to make a request" and add "if a character is deleted, there had to be at least {minChars} to make a request".
        Hide
        Arturo Zambrano added a comment -

        r42011: committed fix to include the last character deleted in the count when comparing against minChars.

        Show
        Arturo Zambrano added a comment - r42011: committed fix to include the last character deleted in the count when comparing against minChars.
        Hide
        Liana Munroe added a comment -

        Verified Icefaces 4 trunk r42011. Tomcat 7, all browsers.

        Show
        Liana Munroe added a comment - Verified Icefaces 4 trunk r42011. Tomcat 7, all browsers.

          People

          • Assignee:
            Arturo Zambrano
            Reporter:
            F Lupke
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: