You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Wicket will search all resource files with the names equal to the components in your component hierarchy, with your application 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. MyPanel_locale.properties, ..., and then MyPanel.properties
2. MyPage_locale.properties, ..., and then MyPage.properties
3. MyApplication_locale.properties, ..., and then MyApplication.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. MyPanel_locale.properties, ..., and then MyPanel.properties
2. Panel_locale.properties, ..., and then Panel.properties
3. MyPage_locale.properties, ..., and then MyPage.properties
4. Page_locale.properties, ..., and then Page.properties
5. MyApplication_locale.properties, ..., and then MyApplication.properties (..)
6. Application_locale.properties, ..., and finally Application.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