javastruts2dependenciesupgradexwork

Field Error keys changing with Xwork upgrade to 2.0.6


I've upgraded Xwork from 2.0.4 to 2.0.6 (struts version is 2.0.11.1). The field validation is working correctly, however the keys for the errors are not. For example, I have a required field called profile.name.firstName. The field error key is now coming up as profile.profile.name.firstName. The first value in the dot-notation is always repeated when the error is coming from Xwork validation.

Any ideas of what could be causing this?


Solution

  • There is a change in the body of getFullFieldName method of class VisitorFieldValidator:

    diff -rNau xwork-2.0.4-sources/ xwork-2.0.6-sources/
    

    Output:

             public String getFullFieldName(String fieldName) {
    +            if (parent instanceof AppendingValidatorContext) {
    +                return parent.getFullFieldName("") + field + "." + fieldName;
    +            }
             return field + "." + fieldName;
         }
    

    Also try to investigate compatibility test results. It seems to be a lot of dangerous changes in the API between 2.0.4 and 2.0.6 (several removed methods). The developers don't follow versioning conventions and I suppose the behavior may change regularly. You cannot update even minor versions without a breakage.