ICEfaces
  1. ICEfaces
  2. ICE-3458

Add maxlength attribute to inputTextarea

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.8.1
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      Use Javascript to replicate similar behavior

      JavaScript:
           <script language="javascript">
                      function textCounter(field,maxlimit) {
                          if (field.value.length > maxlimit)
                              field.value = field.value.substring(0, maxlimit);
                          
                      }
           </script>

      Component:

      <ice:inputTextarea id="text"
                                         cols="50"
                                         rows="3"
                                         value="#{testBean.text}"
                                         onkeydown="textCounter(this, 20)"/>
      Show
      Use Javascript to replicate similar behavior JavaScript:      <script language="javascript">                 function textCounter(field,maxlimit) {                     if (field.value.length > maxlimit)                         field.value = field.value.substring(0, maxlimit);                                      }      </script> Component: <ice:inputTextarea id="text"                                    cols="50"                                    rows="3"                                    value="#{testBean.text}"                                    onkeydown="textCounter(this, 20)"/>

      Description

      The inputText component has a maxlength attribute which will limit the characters in the component. There has been a request for this feature to be added onto the inputTextarea component.

        Issue Links

          Activity

          Arran Mccullough created issue -
          Arran Mccullough made changes -
          Field Original Value New Value
          Priority Major [ 3 ] Minor [ 4 ]
          Support Customer Ref. #s https://www.icesoft.ca:4443/supportilla/show_bug.cgi?id=5139
          Arran Mccullough made changes -
          Workaround Description Use Javascript to replicate similar behavior

          JavaScript:
               <script language="javascript">
                          function textCounter(field,maxlimit) {
                              if (field.value.length > maxlimit)
                                  field.value = field.value.substring(0, maxlimit);
                              
                          }
               </script>

          Component:

          <ice:inputTextarea id="text"
                                             cols="50"
                                             rows="3"
                                             value="#{testBean.text}"
                                             onkeydown="textCounter(this, 20)"/>
          Workaround Exists [Yes]
          Arran Mccullough made changes -
          Salesforce Case [50070000008Jidz]
          Ken Fyten made changes -
          Fix Version/s 1.8.1 [ 10170 ]
          Ken Fyten made changes -
          Assignee Priority P1
          Assignee Mark Collette [ mark.collette ]
          Hide
          Mark Collette added a comment -

          To add some background info, maxlenth is not a standard attribute of textarea, in the html specification. None of the browsers support it. For javascript solutions, there are two main ones: the complicated and more correct solution of capturing the key presses to discard the most recently pressed key, and the simple one that involves truncating the text. The complicated one can fail at handling pasted values, and is tricky to handle non-input key events. The simple one handles those issues fine, but doesn't exactly properly handle things when the caret is not at the end of the textarea. As well, the text that will be truncated does briefly appear before being discarded.

          With all these caveats in mind, we'll go with the simple solution, which is also suggested by the issue originator.

          Show
          Mark Collette added a comment - To add some background info, maxlenth is not a standard attribute of textarea, in the html specification. None of the browsers support it. For javascript solutions, there are two main ones: the complicated and more correct solution of capturing the key presses to discard the most recently pressed key, and the simple one that involves truncating the text. The complicated one can fail at handling pasted values, and is tricky to handle non-input key events. The simple one handles those issues fine, but doesn't exactly properly handle things when the caret is not at the end of the textarea. As well, the text that will be truncated does briefly appear before being discarded. With all these caveats in mind, we'll go with the simple solution, which is also suggested by the issue originator.
          Mark Collette made changes -
          Link This issue depends on ICE-4455 [ ICE-4455 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #18853 Thu May 07 17:22:20 MDT 2009 mark.collette ICE-3458 : Add maxlength attribute to inputTextarea
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/renderkit/dom_html_basic/TextareaRenderer.java
          Commit graph MODIFY /icefaces/trunk/icefaces/component-metadata/src/main/resources/conf/ice_properties/ice-inputTextarea-props.xml
          Commit graph MODIFY /icefaces/trunk/icefaces/bridge/lib/extras/extras.js
          Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/ext/HtmlInputTextarea.java
          Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/ext/renderkit/TextareaRenderer.java
          Hide
          Mark Collette added a comment -

          If an application specifies the maxlength attribute on an ice:inputTextarea component, then onkeydown and onchange listeners will be registered, which will truncate the ending of the text, to remain within the limit of number of characters. Extra characters might appear, and then only be truncated once the user presses another key on the keyboard, or clicks away. Especially if text is pasted in.

          Subversion 18853
          icefaces\bridge\lib\extras\extras.js
          icefaces\component-metadata\src\main\resources\conf\ice_properties\ice-inputTextarea-props.xml
          icefaces\component\src\com\icesoft\faces\component\ext\HtmlInputTextarea.java
          icefaces\component\src\com\icesoft\faces\component\ext\renderkit\TextareaRenderer.java
          icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\TextareaRenderer.java

          Show
          Mark Collette added a comment - If an application specifies the maxlength attribute on an ice:inputTextarea component, then onkeydown and onchange listeners will be registered, which will truncate the ending of the text, to remain within the limit of number of characters. Extra characters might appear, and then only be truncated once the user presses another key on the keyboard, or clicks away. Especially if text is pasted in. Subversion 18853 icefaces\bridge\lib\extras\extras.js icefaces\component-metadata\src\main\resources\conf\ice_properties\ice-inputTextarea-props.xml icefaces\component\src\com\icesoft\faces\component\ext\HtmlInputTextarea.java icefaces\component\src\com\icesoft\faces\component\ext\renderkit\TextareaRenderer.java icefaces\core\src\com\icesoft\faces\renderkit\dom_html_basic\TextareaRenderer.java
          Mark Collette made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Joanne Bai added a comment -

          QA tested it with success on ICEfaces trunk revision 18864

          Test app has been added to the QA repo

          Show
          Joanne Bai added a comment - QA tested it with success on ICEfaces trunk revision 18864 Test app has been added to the QA repo
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19883 Tue Dec 08 12:35:50 MST 2009 judy.guglielmin ICE-4481 updated compat for ICE-3458 and 4455 on HtmlInputTextarea
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/core/src/main/java/com/icesoft/faces/renderkit/dom_html_basic/PassThruAttributeWriter.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/components/src/main/java/com/icesoft/faces/component/ext/renderkit/TextareaRenderer.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/component-metadata/src/main/resources/conf/ice_properties/ice-inputTextarea-props.xml
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/components/src/main/java/com/icesoft/faces/component/ext/HtmlInputTextarea.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/core/src/main/java/com/icesoft/faces/renderkit/dom_html_basic/TextareaRenderer.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/compat/core/src/main/java/com/icesoft/faces/renderkit/dom_html_basic/DomBasicRenderer.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #19884 Tue Dec 08 12:36:20 MST 2009 judy.guglielmin ICE-4481 updated compat for ICE-3458 and 4455 on HtmlInputTextarea
          Files Changed
          Commit graph ADD /icefaces/scratchpads/glimmer/compat/core/src/main/java/com/icesoft/faces/renderkit/dom_html_basic/BaseInputRenderer.java
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1
          Mark Collette made changes -
          Link This issue blocks ICE-5343 [ ICE-5343 ]

            People

            • Assignee:
              Mark Collette
              Reporter:
              Arran Mccullough
            • Votes:
              11 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: