Beehive
  1. Beehive
  2. BEEHIVE-307

Struts validator support for the msg and args' bundle attribute is not working

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: V1Beta, v1m1, 1.0
    • Fix Version/s: 1.0.1
    • Component/s: NetUI
    • Labels:
      None

      Description

      Struts does not correctly get validator msg and args from alternate resource bundles. Struts ignores a bundle attribute defined in the validation XML msg or args element tags used in the commons-validator framework.

      There's already a bug in struts on this. Here's a summary,

      Bug 21760 already includes a patch to go into Struts to resolve this issue. The patch is dependent on some changes in Commons Validator that are part of Validator 1.1.4. Struts is waiting for a "GA" quality release of Validator 1.1.4, then will move the Struts dependency to 1.1.4 and apply the fix.

      and the details...
      http://issues.apache.org/bugzilla/show_bug.cgi?id=21760

      Unfortunately this implies that the NetUI annotations for validator msg and args alternate resource bundles will not work until the fix in struts is integrated into NetUI. User will need to keep msg and args in the default resource bundle.

      1. bundles-test-patch.txt
        8 kB
        Carlin Rogers
      2. j307-patch.txt
        22 kB
        Carlin Rogers

        Activity

        Hide
        Carlin Rogers added a comment -

        Here's a patch that includes a JPF to test the struts validator support
        of the bundle attribute. No need to commit this patch until the struts
        fix has been released and we've integrated with the new version.

        Show
        Carlin Rogers added a comment - Here's a patch that includes a JPF to test the struts validator support of the bundle attribute. No need to commit this patch until the struts fix has been released and we've integrated with the new version.
        Hide
        Steve Tocco added a comment -

        moving to v1 (if not needed for ship, please move to Fix For = TBD)

        Show
        Steve Tocco added a comment - moving to v1 (if not needed for ship, please move to Fix For = TBD)
        Hide
        Carlin Rogers added a comment -

        Changing fix for to "TBD".

        The Struts bugzilla issue, 21760, has been resolved in the
        Struts 1.2.x branch of code. However, it is unlikely the
        next 1.2.x release (1.2.7 ?) will come in time for a beehive
        v1.0 release.

        Show
        Carlin Rogers added a comment - Changing fix for to "TBD". The Struts bugzilla issue, 21760, has been resolved in the Struts 1.2.x branch of code. However, it is unlikely the next 1.2.x release (1.2.7 ?) will come in time for a beehive v1.0 release.
        Hide
        Carlin Rogers added a comment -

        Assigning to Rich to consider an upgrade of NetUI to use Struts 1.2.7.
        Struts bug 21760 was fixed in the Struts 1.2.x on 3/29/2005 and should be
        part of the Struts 1.2.7 release.

        There was a Struts announcement on 5/26/2005 about the GA release
        of 1.2.7.

        With the upgrade we should be able to close this bug.

        Show
        Carlin Rogers added a comment - Assigning to Rich to consider an upgrade of NetUI to use Struts 1.2.7. Struts bug 21760 was fixed in the Struts 1.2.x on 3/29/2005 and should be part of the Struts 1.2.7 release. There was a Struts announcement on 5/26/2005 about the GA release of 1.2.7. With the upgrade we should be able to close this bug.
        Hide
        Rich Feit added a comment -

        Fixed with revision 190814. Carlin, thanks for identifying the root issue.

        Show
        Rich Feit added a comment - Fixed with revision 190814. Carlin, thanks for identifying the root issue.
        Hide
        Alejandro Ramirez added a comment -

        Carlin,
        I used the pageflow that you attached (in the form of a patch) and entered the following values for the form:
        Item 1: 1
        Item 2: 12345
        Item 3: 1234
        Item 4: 1234567890

        Expected: All validation for the form properties should fail and correct messages should be displayed.
        Actual: Validation failed, however, the error and errors tags displayed the following "tag error messages:

        Error Number Tag Type Error
        1 Error Message Could not find a message for message key "Maximum length validation: item two cannot be more than four chars." in the default message bundle for the current page flow.
        2 Error Message Could not find a message for message key "Maximum length validation: item four cannot be more than eight chars." in the default message bundle for the current page flow.
        3 Errors Message Could not find a message for message key "Maximum length validation: item four cannot be more than eight chars." in the default message bundle for the current page flow.
        4 Errors Message Could not find a message for message key "Maximum length validation: item two cannot be more than four chars." in the default message bundle for the current page flow.

        Show
        Alejandro Ramirez added a comment - Carlin, I used the pageflow that you attached (in the form of a patch) and entered the following values for the form: Item 1: 1 Item 2: 12345 Item 3: 1234 Item 4: 1234567890 Expected: All validation for the form properties should fail and correct messages should be displayed. Actual: Validation failed, however, the error and errors tags displayed the following "tag error messages: Error Number Tag Type Error 1 Error Message Could not find a message for message key "Maximum length validation: item two cannot be more than four chars." in the default message bundle for the current page flow. 2 Error Message Could not find a message for message key "Maximum length validation: item four cannot be more than eight chars." in the default message bundle for the current page flow. 3 Errors Message Could not find a message for message key "Maximum length validation: item four cannot be more than eight chars." in the default message bundle for the current page flow. 4 Errors Message Could not find a message for message key "Maximum length validation: item two cannot be more than four chars." in the default message bundle for the current page flow.
        Hide
        Carlin Rogers added a comment -

        I'll look at this right now. If there's still an issue I think this one could go back to TBD and not
        hold up V1.

        Show
        Carlin Rogers added a comment - I'll look at this right now. If there's still an issue I think this one could go back to TBD and not hold up V1.
        Hide
        Carlin Rogers added a comment -

        We still need to make a change on the NetUI side. The struts validator Resources
        class formats the validation error using the alternate bundle and then creates a
        struts ActionMessage for the error. However, this ActionMessage is a little different
        from the others that our ErrorBaseTag handle.

        The error ActionMessage objects usually have the key being the actual key or the
        key is the message but identified by a leading "NETUI-EXPRESSION:" to indicate
        that we don't need to get the messsage from the default bundle.

        In this case we have a message and not a real key but it does not start with the
        leading "NETUI-EXPRESSION:" so we treat it as a key and actually try to look up
        the message from the default bundle.

        The fix will require some changes, probably in the NetUI ErrorBaseTag. I will go
        ahead and make a patch. At this stage in preparing to release for V1, I think we
        should move this back to TBD, unless anyone objects.

        Thoughts?

        Show
        Carlin Rogers added a comment - We still need to make a change on the NetUI side. The struts validator Resources class formats the validation error using the alternate bundle and then creates a struts ActionMessage for the error. However, this ActionMessage is a little different from the others that our ErrorBaseTag handle. The error ActionMessage objects usually have the key being the actual key or the key is the message but identified by a leading "NETUI-EXPRESSION:" to indicate that we don't need to get the messsage from the default bundle. In this case we have a message and not a real key but it does not start with the leading "NETUI-EXPRESSION:" so we treat it as a key and actually try to look up the message from the default bundle. The fix will require some changes, probably in the NetUI ErrorBaseTag. I will go ahead and make a patch. At this stage in preparing to release for V1, I think we should move this back to TBD, unless anyone objects. Thoughts?
        Hide
        Carlin Rogers added a comment -

        The following patch includes a fix to the ErrorbaseTag.getErrorMessage() method to check if
        the error ActionMessage is a resource or not. If not, then we just get the already formatted
        message and return. This fix is in place because the struts validator Resources class will
        format the message using the alternate resource bundle and create the new ActionMessage
        with resource=false.

        The patch also has the updated test files along with a new testRecorder BVT.

        Show
        Carlin Rogers added a comment - The following patch includes a fix to the ErrorbaseTag.getErrorMessage() method to check if the error ActionMessage is a resource or not. If not, then we just get the already formatted message and return. This fix is in place because the struts validator Resources class will format the message using the alternate resource bundle and create the new ActionMessage with resource=false. The patch also has the updated test files along with a new testRecorder BVT.
        Hide
        Carlin Rogers added a comment -

        Assigning to Rich for review. The fix is just a three line diff but I still think this
        could go in post V1 unless others feel strongly that this needs to go in this
        release.

        Show
        Carlin Rogers added a comment - Assigning to Rich for review. The fix is just a three line diff but I still think this could go in post V1 unless others feel strongly that this needs to go in this release.
        Hide
        Rich Feit added a comment -

        Committed the patch with revision 290884. Thanks Carlin!

        Show
        Rich Feit added a comment - Committed the patch with revision 290884. Thanks Carlin!
        Hide
        Julie Zhuo added a comment -

        Verified with rev374489. The ValidatorMsgBundles test has various combination of validation messges (with keys or without keys). They are all working propertly now. Close.

        Show
        Julie Zhuo added a comment - Verified with rev374489. The ValidatorMsgBundles test has various combination of validation messges (with keys or without keys). They are all working propertly now. Close.

          People

          • Assignee:
            Julie Zhuo
            Reporter:
            Carlin Rogers
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development