Wicket will search all resource files with the names equal to the components in your component hierarchy, starting from application level at top to component defaults as a last resort.

So when Wickets wants to look up a message used in MyPanel, where MyPanel is contained within MyPage, and the application is called MyApplication, Wicket will look in:
1. MyApplication_locale.properties, ..., and then MyApplication.properties (..)
2. MyPage_locale.properties, ..., and then MyPage.properties
3. MyPanel_locale.properties, ..., and then MyPanel.properties

Actually, it even goes two steps further. Wicket will also look at property files for the base classes of MyPanel, MyPage and MyApplication.
When MyPanel inherites directly from Panel, MyPage directly from Page and MyApplication directly from Application, Wicket will look in:
1. Application_locale.properties, ..., and Application.properties (..)
2. MyApplication_locale.properties, ..., and then MyApplication.properties (..)
3. Page_locale.properties, ..., and then Page.properties
4. MyPage_locale.properties, ..., and then MyPage.properties
5. Panel_locale.properties, ..., and then Panel.properties
6. MyPanel_locale.properties, ..., and finally MyPanel.properties

In conclusion: you can use MyApplication.properties for site wide messages and override these in any of the other properties files.

The second extension of this is styles and variants. Styles and variants are not suitable for i18n.

Load resources dynamically for a component

  1. Properties.load(PackageResource.get(MyComponent.class, "MyComponent.properties").getResourceStream().getInputStream()));
  1. Alternatively, you can get the resource from the class loader... this.getClass().getClassLoader().getResouceAsStream("MyComponent.properties");
  • No labels