Struts 1
  1. Struts 1
  2. STR-3193

Locale Date Validation with Client Side Javascript

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.10
    • Fix Version/s: Pending Review
    • Component/s: Tag Libraries
    • Labels:
      None
    • Environment:
      Windows XP or Suse 10.2, JBoss 4.2.3, Struts 1.3.10, JDK1.5_16
    • Flags:
      Patch, Important

      Description

      This bug has to do with the struts-taglib package, specifically the code generated by <html:javascript> which comes from the org.apache.struts.taglib.html.JavascriptValidatorTag class.

      My implementation of the patch may not be the most effective way to accomplish this, but the bug prevents a true Locale specific implementation of Forms with Dates.

      From the Struts Validation Documentation (which holds true on the server side validation):
      "If no pattern is specified the default short date format is assumed."

      However, if you define a Form Field as a "date" with no pattern, the client side javascript does not render the datePattern in the javascript and causes a clientside js NPE when checking the length of this.datePattern.

      I have added an additional method for formatting the Locale SHORT date format to fill out in the MM, dd, and yyyy elements required by the static javascript generator from the Commons-Validator project.

      The real patch is when looping over form fields from validation.xml. I check if it is a type "date" then keep track of whether or not a var named "datePattern" exists. If not, I add datePattern based on the Local passed in.

      Please let me know if I can help. This is a really important feature for my application.

      1. Struts.patch
        3 kB
        David Webb
      2. JavascriptValidatorTag.java.patch
        3 kB
        David Webb

        Activity

        David Webb created issue -
        David Webb made changes -
        Field Original Value New Value
        Attachment JavascriptValidatorTag.java.patch [ 14066 ]
        Attachment Struts.patch [ 14067 ]
        David Webb made changes -
        Assignee Paul Benedict [ paul4christ79 ]
        Paul Benedict made changes -
        Fix Version/s Pending Review [ 21866 ]
        Jeff Turner made changes -
        Project Import Mon Feb 01 01:03:21 UTC 2010 [ 1264986201992 ]
        Mark Thomas made changes -
        Workflow jira [ 12492878 ] Default workflow, editable Closed status [ 12545257 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12545257 ] jira [ 12548255 ]
        Mark Thomas made changes -
        Workflow jira [ 12548255 ] Default workflow, editable Closed status [ 12558367 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12558367 ] jira [ 12587011 ]

          People

          • Assignee:
            Paul Benedict
            Reporter:
            David Webb
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development