Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2704

FormComponent.MessageSource.getMessage(String) and getValidatorKeyPrefix()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4.3, 1.4.4, 1.4.5
    • 1.4.7, 1.5-M1
    • wicket
    • None

    Description

      I tried to use the getValidatorKeyPrefix() feature to have a more suitable translation key for a RequiredTextField and the « required » message.
      But Wicket wasn't able to find my key : the debug log said that it couldn't find my key whereas it is well-formed (getValidatorKeyPrefix() + ".Required").
      So i debugged the getMessage(String) and I understood the problem. Arround the line 175 (in Wicket 1.4.5) we find :
      // If not found try a more general form [prefix].[key]
      if (Strings.isEmpty(message))
      {
      resource = prefix(prefix, key);
      message = getString(localizer, key, formComponent);
      }

      The comment is good, but the code is wrong : the resource variable isn't used in the getString(...) ! (I think it's a kind of bad copy/paste from surrounding code)
      We should find :
      message = getString(localizer, resource, formComponent);

      I did it and it works.

      Attachments

        Activity

          People

            jdonnerstag Juegen Donnerstag
            guiom.mary Guillaume Mary
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: