Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2103

Invalid Javascript generated for StringLength validator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.9
    • 2.0.10
    • None
    • None
    • NetBeans IDE 5.5.1 (Bundled Tomcat 5.5.17), Java 1.6

    Description

      I am attempting to use the StringLength validator for an action's "save" alias, to ensure that a text-field input is between 3 and 1024 characters long (the minLength and maxLength params, respectively). When testing the validation, I noticed that strings of any length were being rejected by the client-side Javascript validation (I am using the xhtml theme). Looking at the generated Javascript code in the page source, it appears the problem is that my maxLength parameter is being printed with locale formatting (as it is in when substituted into my error message), rather than as a raw number:

      if(value.length > 0 && (
      (3 > -1 && value.length < 3) ||
      (1,024 > -1 && value.length > 1,024)
      ))

      { addError(field, error); errors = true; }

      Attachments

        1. form-close-validate.ftl.patch
          3 kB
          Florent Ramière
        2. struts2-form-close-validate.ftl.patch
          3 kB
          Florent Ramière

        Activity

          People

            jholmes James Holmes
            jmikola Jeremy Mikola
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: