Uploaded image for project: 'XWork'
  1. XWork
  2. XW-737

ValidatorSupport turns empty defaultMessage to null causing field error to include "null" for visitor validators with empty messages

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1.6
    • 2.1.7
    • Validators
    • None
    • struts 2.1.8, xwork 2.1.6, jdk 1.6
    • Patch

    Description

      Upon upgrading to struts 2.1.8 with xwork 2.1.6, I started getting field errors which included the string null in them for field visitor validators.

      Using a visitor validator as follows:

      <field name="residenceRoom">

      <field-validator type="visitor">

      <message/>

      </field-validator>

      </field>

      and a required string validator on the actual field as follows:

      <field name="description">

      <field-validator type="requiredstring">

      <message>Description is required</message>

      </field-validator>

      </field>

      I was expecting only the message "Description is required" but I end up with "nullDescription is required". Presumably this happens because of line 202 in VisitorFieldValidator.java

      super.addFieldError(getFullFieldName(fieldName), message + errorMessage);

      The fix for me seems to be to fix ValidatorSupport to not nullify defaultMessage when message is null or empty. I will attach a patch shortly.

      Attachments

        Activity

          People

            lukasz03 Disabled - L-u-k-a-s-z Lenart - OpenSymphony
            corporate_gadfly Haroon Rafique
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: