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

PackageStringResourceLoader does not look up to superclasses

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.2
    • 1.4.4, 1.5-M1
    • wicket
    • None

    Description

      From wicket-devlist:
      "ComponentStringResourceLoader attempts to find the resource from given component stack and if not found, then it tries to find a resource in component class hierarchy. Method:
      public String loadStringResource(Class<?> clazz, final String key, final Locale locale, final String style)
      performs a loop through superclasses of the given clazz.

      But in PackageStringResourceLoader implementation the same method only checks the given clazz and does not perform a check in superclasses. I think it should to handle such scenario:
      1. Component com.aaa.CompA has a resource string defined in "package.properties" file in package com.aaa.
      2. In some other package (eg. com.bbb) I'm using CompA component and overriding its one method (so I've created a new subclass of CompA). Then resource strings from "package.properties" in package com.aaa will not be loaded."

      I've attached a quickstart app. It contains a simple implementation of PackageStringResourceLoader (PackageSuperStringResourceLoader - for demonstration purposes only) which look up superclasses to find a resource string.

      When you run this app and enter a HomePage you should see an error:
      java.util.MissingResourceException: Unable to find property: 'sampleKey' for component: panel2 [class=com.company.application.HomePage$1]

      When you uncomment this line in WicketApplication init() method:
      getResourceSettings().addStringResourceLoader(new PackageSuperStringResourceLoader());
      then HomePage renders ok.

      Attachments

        1. packageres.zip
          10 kB
          Daniel Stoch

        Activity

          People

            jdonnerstag Juegen Donnerstag
            interface Daniel Stoch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: