Example usage for org.apache.wicket Component getVariation

List of usage examples for org.apache.wicket Component getVariation

Introduction

In this page you can find the example usage for org.apache.wicket Component getVariation.

Prototype

public String getVariation() 

Source Link

Document

Gets the variation string of this component that will be used to look up markup for this component.

Usage

From source file:de.inren.frontend.application.InRenApplication.java

License:Apache License

/**
 * I'm lazy some times. Don't throw exceptions when properties are missing,
 * just remind me with a default value (the key+locale).
 *//*from   www  .  java2s .  c  o m*/
private void initializeFailSafeLocalize() {
    Localizer localizer = new Localizer() {

        @Override
        public String getString(String key, Component component, IModel<?> model, Locale locale, String style,
                String defaultValue) throws MissingResourceException {
            try {
                return super.getString(key, component, model, locale, style, defaultValue);
            } catch (MissingResourceException e) {
                String variation = (component != null ? component.getVariation() : null);
                String cacheKey = getCacheKey(key, component, locale, style, variation);
                log.info("######### Missing: cacheKey=[" + cacheKey + "] " + e.getMessage());
                final String text = key + (locale == null ? "" : locale.getLanguage());
                return "[" + text + "]";
            }
        }

    };
    this.getResourceSettings().setLocalizer(localizer);
}