Uploaded image for project: 'Velocity Tools'
  1. Velocity Tools
  2. VELTOOLS-58

ValidatorTool does not respect 'bundle' property for message elements when generating client-side validation code.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2, 1.3
    • Fix Version/s: 1.3
    • Component/s: VelocityStruts
    • Labels:
      None
    • Environment:
      JDK 1.4.2_09 / Tomcat 4.1.31 / Struts 1.2.7 / Commons-Validator 1.1.4

      Description

      I recently decided to split my application properties files into multiple bundles instead of one huge bundle in an effort to maintain some order. This required me to change my validation configuration to include the "bundle" property on my message elements:

      <field property="questionTypeId"
      depends="required,integer">
      <arg position="0" bundle="Clinician" key="prompt.responseOption.questionTypeId"/>
      </field>

      The ValidatorTool.getDynamicJavascript does not respect this setting and so I get messages like "The field ?en_US.responseOption.questionTypeId? is required.".

      ValidatorTool.getDynamicJavascript first gets the global message bundle and re-uses it for all of the error messages emitted by the javascript generator:

      String message = Resources.getMessage(messages, locale, va, field);

      In order to respect the <msg>'s bundle, the code should instead be this:

      String message = Resources.getMessage(app,
      request,
      messages,
      locale,
      va,
      field);

      It turns out that this doesn't fix the problem, although I'm sure that this change should be made. Perhaps someone with a better understanding of Struts/Validator/VelocityTools could shed some light on this situation.

        Attachments

        1. VELTOOLS-58.patch
          0.8 kB
          Christopher Schultz
        2. ValidatorTool.java
          28 kB
          Nathan Bubna

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chris@christopherschultz.net Christopher Schultz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: