MyFaces Tobago
  1. MyFaces Tobago
  2. TOBAGO-626

Input length restriction for tc:textarea

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.16
    • Fix Version/s: 1.0.21, 1.5.0
    • Component/s: Themes
    • Labels:
      None
    • Environment:
      All / IE

      Description

      The length of the input text in a tc:textrea should be restricted by the browser like it is in tc:in

      1. TOBAGO-626-theme-scarborough.diff
        2 kB
        Helmut Swaczinna
      2. TOBAGO-626-theme-standard.diff
        1 kB
        Helmut Swaczinna
      3. TOBAGO-626-core.diff
        0.6 kB
        Helmut Swaczinna

        Issue Links

          Activity

          Hide
          Helmut Swaczinna added a comment -

          Problem solved. Patches are based on current 1.0.16 sources.

          Restricting the input length when the user types in the text works for all browser.
          Restricting the input length when the user pastes in the text works only for IE

          Show
          Helmut Swaczinna added a comment - Problem solved. Patches are based on current 1.0.16 sources. Restricting the input length when the user types in the text works for all browser. Restricting the input length when the user pastes in the text works only for IE
          Hide
          Volker Weber added a comment -

          Hi,

          afaik in IE the event object is not parameter of event functions. you need something like

          function fnName(event)

          { if (!event) event = window.event; ... }

          You may look here
          http://www.thescripts.com/forum/thread151196.html
          for a FF onpaste solution.

          Show
          Volker Weber added a comment - Hi, afaik in IE the event object is not parameter of event functions. you need something like function fnName(event) { if (!event) event = window.event; ... } You may look here http://www.thescripts.com/forum/thread151196.html for a FF onpaste solution.
          Hide
          Helmut Swaczinna added a comment -

          Hi Volker,

          yes, I saw this many times, but it works fine without in IE 6. Maybe not in IE < 6? Can't test this.

          Show
          Helmut Swaczinna added a comment - Hi Volker, yes, I saw this many times, but it works fine without in IE 6. Maybe not in IE < 6? Can't test this.
          Hide
          Helmut Swaczinna added a comment -

          >You may look here
          >http://www.thescripts.com/forum/thread151196.html
          >for a FF onpaste solution.

          Yes, but you can't easily access the clipboard in FF (afaik) and I don't know if there's something like
          the IE TextRange object in FF. I think the only way to restrict the input length in FF on pasting is
          truncating the whole text after pasting.

          Show
          Helmut Swaczinna added a comment - >You may look here > http://www.thescripts.com/forum/thread151196.html >for a FF onpaste solution. Yes, but you can't easily access the clipboard in FF (afaik) and I don't know if there's something like the IE TextRange object in FF. I think the only way to restrict the input length in FF on pasting is truncating the whole text after pasting.
          Hide
          Volker Weber added a comment -

          if you need the TextRange to insert the pasteText on curserPos:

          if (typeof textarea.selectionStart != 'undefined')

          { /* für neuere auf Gecko basierende Browser */ start = textarea.value.substr(0,textarea.selectionStart); end = textarea.value.substr(textarea.selectionEnd); textarea.value = start + pasteText + end; }

          else if (typeof document.selection != 'undefined') {
          /* für Internet Explorer */
          ...

          Show
          Volker Weber added a comment - if you need the TextRange to insert the pasteText on curserPos: if (typeof textarea.selectionStart != 'undefined') { /* für neuere auf Gecko basierende Browser */ start = textarea.value.substr(0,textarea.selectionStart); end = textarea.value.substr(textarea.selectionEnd); textarea.value = start + pasteText + end; } else if (typeof document.selection != 'undefined') { /* für Internet Explorer */ ...
          Hide
          Bernd Bohmann added a comment -

          Start with an implementation based on the trinidad javascript in 1.1.x.
          Will be merged after some tests to 1.0.x

          Show
          Bernd Bohmann added a comment - Start with an implementation based on the trinidad javascript in 1.1.x. Will be merged after some tests to 1.0.x
          Hide
          Bernd Bohmann added a comment -

          Helmut,

          can you check the current implementation in 1.0.x, please?

          Regards

          Bernd.

          Show
          Bernd Bohmann added a comment - Helmut, can you check the current implementation in 1.0.x, please? Regards Bernd.
          Hide
          Helmut Swaczinna added a comment -

          Hi Bernd,

          yes, it works in IE and FF. But ... this solution is really ugly
          The flickering at the and of the string. The cursor always jumps to
          the end of the string. And the behaviour of tc:textarea is now completely
          different from tc:in.
          Ok, in FF there seems to be no other possibilty, but my solution for IE
          was much better. I don't think, I can present this to our customers.
          Fortunately, they're using the IE

          Regards
          Helmut

          Show
          Helmut Swaczinna added a comment - Hi Bernd, yes, it works in IE and FF. But ... this solution is really ugly The flickering at the and of the string. The cursor always jumps to the end of the string. And the behaviour of tc:textarea is now completely different from tc:in. Ok, in FF there seems to be no other possibilty, but my solution for IE was much better. I don't think, I can present this to our customers. Fortunately, they're using the IE Regards Helmut
          Hide
          Helmut Swaczinna added a comment -

          Hi Bernd,

          it does not work when you paste text by mouse (menu command)!

          Regards
          Helmut

          Show
          Helmut Swaczinna added a comment - Hi Bernd, it does not work when you paste text by mouse (menu command)! Regards Helmut
          Hide
          Bernd Bohmann added a comment -

          I try to integrate your javascript.

          Show
          Bernd Bohmann added a comment - I try to integrate your javascript.
          Hide
          Bernd Bohmann added a comment -

          Maybe the keypress event is a better choice.
          Can't really test and debug the paste event on firefox (linux).

          Show
          Bernd Bohmann added a comment - Maybe the keypress event is a better choice. Can't really test and debug the paste event on firefox (linux).
          Hide
          Helmut Swaczinna added a comment -

          The keypress event is not sufficient because it does not cover pasting test by mouse (menu command)

          Show
          Helmut Swaczinna added a comment - The keypress event is not sufficient because it does not cover pasting test by mouse (menu command)
          Hide
          Bernd Bohmann added a comment -

          Hello Helmut,

          i think keypress is a better choice instead of keyup. Arvid has tested and fixed the onpaste on IE Windows, now.
          Can you test the latest version of trunk, please.

          Show
          Bernd Bohmann added a comment - Hello Helmut, i think keypress is a better choice instead of keyup. Arvid has tested and fixed the onpaste on IE Windows, now. Can you test the latest version of trunk, please.
          Hide
          Helmut Swaczinna added a comment -

          No, I can't. Checked out the trunk but get build errors. Please backport to 1.0.x.
          Helmut

          Show
          Helmut Swaczinna added a comment - No, I can't. Checked out the trunk but get build errors. Please backport to 1.0.x. Helmut
          Hide
          Bernd Bohmann added a comment -

          Ok, I will add a coment when the changes are backported.

          Can you sent me the compile errors of trunk, please.

          Show
          Bernd Bohmann added a comment - Ok, I will add a coment when the changes are backported. Can you sent me the compile errors of trunk, please.
          Hide
          Helmut Swaczinna added a comment -

          [INFO] [apt:process

          {execution: tobago-tlds}

          ]
          [INFO] Processing 359 source files to C:\Projekte\jsf\tobago-src-1.1.x\core\target\generated-tld
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:53: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createTextColumn(String label, String sortable, String align, String value)
          {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:57: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createTextColumn(String label, String sortable, String align, String value,
          String clientId) {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:66: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createColumn(String label, String sortable, String align, UIComponent child
          ) {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:69: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createColumn(String label, String sortable, String align, UIComponent child
          , String clientId) {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:77: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createColumn(String label, String sortable, String align) {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon
          entUtils.java:81: cannot find symbol
          symbol : class UIColumn
          location: class org.apache.myfaces.tobago.component.CreateComponentUtils
          public static UIColumn createColumn(String label, String sortable, String align, String clientId)
          {
          ^
          C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\UIDatePicker
          .java:32: cannot find symbol
          symbol: class UILinkCommand
          public class UIDatePicker extends UILinkCommand implements OnComponentCreated {
          ^
          Note: Some input files use or override a deprecated API.
          Note: Recompile with -Xlint:deprecation for details.
          [INFO] [apt:process

          {execution: tobago-components}

          ]
          [INFO] Processing 358 source files to C:\Projekte\jsf\tobago-src-1.1.x\core\target\generated-compone
          nt
          [WARNING] Der Befehl "apt" ist entweder falsch geschrieben oder
          [WARNING] konnte nicht gefunden werden.
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] Apt failed
          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 14 seconds
          [INFO] Finished at: Tue Feb 17 12:52:25 CET 2009
          [INFO] Final Memory: 25M/63M
          [INFO] ------------------------------------------------------------------------

          Show
          Helmut Swaczinna added a comment - [INFO] [apt:process {execution: tobago-tlds} ] [INFO] Processing 359 source files to C:\Projekte\jsf\tobago-src-1.1.x\core\target\generated-tld C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:53: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createTextColumn(String label, String sortable, String align, String value) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:57: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createTextColumn(String label, String sortable, String align, String value, String clientId) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:66: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createColumn(String label, String sortable, String align, UIComponent child ) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:69: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createColumn(String label, String sortable, String align, UIComponent child , String clientId) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:77: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createColumn(String label, String sortable, String align) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\CreateCompon entUtils.java:81: cannot find symbol symbol : class UIColumn location: class org.apache.myfaces.tobago.component.CreateComponentUtils public static UIColumn createColumn(String label, String sortable, String align, String clientId) { ^ C:\Projekte\jsf\tobago-src-1.1.x\core\src\main\java\org\apache\myfaces\tobago\component\UIDatePicker .java:32: cannot find symbol symbol: class UILinkCommand public class UIDatePicker extends UILinkCommand implements OnComponentCreated { ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. [INFO] [apt:process {execution: tobago-components} ] [INFO] Processing 358 source files to C:\Projekte\jsf\tobago-src-1.1.x\core\target\generated-compone nt [WARNING] Der Befehl "apt" ist entweder falsch geschrieben oder [WARNING] konnte nicht gefunden werden. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Apt failed [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 14 seconds [INFO] Finished at: Tue Feb 17 12:52:25 CET 2009 [INFO] Final Memory: 25M/63M [INFO] ------------------------------------------------------------------------
          Hide
          Bernd Bohmann added a comment -

          I have merged the changes to the branch.

          In 1.1 we are using the apt-maven-plugin from codehaus. This plugin expects the apt executable in the path. The old apt plugin from tobago used JAVA_HOME for executing the apt plugin.

          Maybe i will open an issue at mojo.codehaus.

          Regards

          Bernd

          Show
          Bernd Bohmann added a comment - I have merged the changes to the branch. In 1.1 we are using the apt-maven-plugin from codehaus. This plugin expects the apt executable in the path. The old apt plugin from tobago used JAVA_HOME for executing the apt plugin. Maybe i will open an issue at mojo.codehaus. Regards Bernd
          Hide
          Helmut Swaczinna added a comment -

          Hi Bernd,

          sorry, but the behaviour is now not only ugly but incorrect (both browsers, 1.0.21):

          First, you can type in one more character as specified.
          Second, when you type in the middle of the string and the maximum length is
          reached, the cursor jumps to the end of the string and the typed character is appended
          at the end.

          Pasting is handled correct in IE.

          P.S. Building the trunk now works.

          Show
          Helmut Swaczinna added a comment - Hi Bernd, sorry, but the behaviour is now not only ugly but incorrect (both browsers, 1.0.21): First, you can type in one more character as specified. Second, when you type in the middle of the string and the maximum length is reached, the cursor jumps to the end of the string and the typed character is appended at the end. Pasting is handled correct in IE. P.S. Building the trunk now works.

            People

            • Assignee:
              Bernd Bohmann
              Reporter:
              Helmut Swaczinna
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development