ICEfaces
  1. ICEfaces
  2. ICE-2743

Add textChangedListener to selectInputText

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7Beta1
    • Fix Version/s: 1.7RC1, 1.7
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All
    • Affects:
      Sample App./Tutorial

      Description

      The selectInputText component already has a valueChangeListener, for being notified of a valid new value, which can be triggered by text being typed, tabbing out of the component, pressing enter, or selecting an entry from the popup list. What is lacks is a listener mechanism solely focussed on notifying when the user has typed, or deleted, character(s), and thus should change the popup list of options. This textChangedListener would still receive a ValueChangeEvent, except that the values in the event would be the changing submittedValue, not the converted and validated value. This would also allow for notifications when the partially entered text fails conversion or validation, as that would not trigger the valueChangeListener.

        Issue Links

          Activity

          Hide
          Mark Collette added a comment -

          Added a MethodBinding to SelectInputText called textChangeListener, which takes a TextChangeEvent parameter. TextChangeEvent extends ValueChangeEvent, and the whole things acts like ValueChangeEvent/ValueChangeListener. Although the TextChangeEvent is broadcast in the APPLY_REQUEST_VALUES phase and contains the SelectInputText's submittedValue as its new value.

          It's purpose is to notify the application that the user has typed in a text fragment into the SelectInputText's text input field, allowing for the application to refine its selection list which will popup. In the case of converted and validated values, which require a complete
          input of text, like with a Date, the textChangeListener may call FacesContext.getCurrentInstance().renderResponse() to skip over the validation, and proceed to rendering the popup selection list.

          HEAD
          Subversion 15838
          icefaces\bridge\lib\extras\autocomplete_ext.js
          icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java
          icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml
          icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java
          icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java

          ICEfaces 1.6 branch
          Subversion 15839
          icefaces\bridge\lib\extras\autocomplete_ext.js
          icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java
          icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml
          icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java
          icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java
          icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java

          Show
          Mark Collette added a comment - Added a MethodBinding to SelectInputText called textChangeListener, which takes a TextChangeEvent parameter. TextChangeEvent extends ValueChangeEvent, and the whole things acts like ValueChangeEvent/ValueChangeListener. Although the TextChangeEvent is broadcast in the APPLY_REQUEST_VALUES phase and contains the SelectInputText's submittedValue as its new value. It's purpose is to notify the application that the user has typed in a text fragment into the SelectInputText's text input field, allowing for the application to refine its selection list which will popup. In the case of converted and validated values, which require a complete input of text, like with a Date, the textChangeListener may call FacesContext.getCurrentInstance().renderResponse() to skip over the validation, and proceed to rendering the popup selection list. HEAD Subversion 15838 icefaces\bridge\lib\extras\autocomplete_ext.js icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java ICEfaces 1.6 branch Subversion 15839 icefaces\bridge\lib\extras\autocomplete_ext.js icefaces\component-metadata\src\main\java\com\icesoft\metadata\generators\TagLibraryGenerator.java icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-selectinputtext-props.xml icefaces\component\src\com\icesoft\faces\component\facelets\IceComponentHandler.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputText.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\SelectInputTextRenderer.java icefaces\component\src\com\icesoft\faces\component\selectinputtext\TextChangeEvent.java icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\DomBasicRenderer.java
          Hide
          Mark Collette added a comment -

          An example of using the new textChangeListener, to allow for converted data types:

          <ice:selectInputText
          rows="15" width="300"
          textChangeListener="#

          {autoCompleteBean.textChanged}

          "
          valueChangeListener="#

          {autoCompleteBean.valueChanged}

          ">
          <f:convertDateTime type="both" dateStyle="full" timeStyle="full"/>
          <f:selectItems value="#

          {autoCompleteBean.list}

          "/>
          </ice:selectInputText>

          public void textChanged(TextChangeEvent event) {
          String text = (String) event.getNewValue();
          if(text == null || text.length() == 0)

          { // The user pressed the DOWN key, so show the full list, or the first few entries, or whatever your policy is }

          else

          { // Use the partial text fragment to determine which subset of the complete list to show // Add items to list, with null labels, so the component will make them using the f:convertDateTime automatically // Date d = new Date(); // SelectItem si = new SelectItem(d, null); // list.add(si); // If the fragment would fail conversion or validation, and you don't want a FacesMessage to show, then do this: FacesContext.getCurrentInstance().renderResponse(); }

          }

          public void valueChanged(ValueChangeEvent event) {
          // Once a full value has been typed in or selected, and passed conversion and validation,
          // we can access it here
          Date d = (Date) event.getNewValue();

          // The same thing should be accessible here:
          Date d2 = (Date) ( (SelectInputText) event.getComponent() ).getValue();

          // In case you need the actual SelectItem that was selected, if one was selected
          SelectInputText autoComplete = (SelectInputText) event.getComponent();
          if (autoComplete.getSelectedItem() != null)

          { Date d3 = (Date) autoComplete.getSelectedItem().getValue(); }

          }

          // ArrayList< SelectItem<Date> >
          public List getList()

          { return list; }
          Show
          Mark Collette added a comment - An example of using the new textChangeListener, to allow for converted data types: <ice:selectInputText rows="15" width="300" textChangeListener="# {autoCompleteBean.textChanged} " valueChangeListener="# {autoCompleteBean.valueChanged} "> <f:convertDateTime type="both" dateStyle="full" timeStyle="full"/> <f:selectItems value="# {autoCompleteBean.list} "/> </ice:selectInputText> public void textChanged(TextChangeEvent event) { String text = (String) event.getNewValue(); if(text == null || text.length() == 0) { // The user pressed the DOWN key, so show the full list, or the first few entries, or whatever your policy is } else { // Use the partial text fragment to determine which subset of the complete list to show // Add items to list, with null labels, so the component will make them using the f:convertDateTime automatically // Date d = new Date(); // SelectItem si = new SelectItem(d, null); // list.add(si); // If the fragment would fail conversion or validation, and you don't want a FacesMessage to show, then do this: FacesContext.getCurrentInstance().renderResponse(); } } public void valueChanged(ValueChangeEvent event) { // Once a full value has been typed in or selected, and passed conversion and validation, // we can access it here Date d = (Date) event.getNewValue(); // The same thing should be accessible here: Date d2 = (Date) ( (SelectInputText) event.getComponent() ).getValue(); // In case you need the actual SelectItem that was selected, if one was selected SelectInputText autoComplete = (SelectInputText) event.getComponent(); if (autoComplete.getSelectedItem() != null) { Date d3 = (Date) autoComplete.getSelectedItem().getValue(); } } // ArrayList< SelectItem<Date> > public List getList() { return list; }
          Hide
          Mark Collette added a comment -

          We should add usage of the textChangeListener somewhere in the component-showcase.

          Show
          Mark Collette added a comment - We should add usage of the textChangeListener somewhere in the component-showcase.

            People

            • Assignee:
              Unassigned
              Reporter:
              Mark Collette
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: