in wicket-core/src/main/java/org/apache/wicket/Localizer.java [320:426]
public String getStringIgnoreSettings(final String key, final Component component,
final IModel<?> model, Locale locale, String style, final String defaultValue)
{
boolean addedToPage = false;
if (component != null)
{
if ((component instanceof Page) || (null != component.findParent(Page.class)))
{
addedToPage = true;
}
if (!addedToPage && log.isWarnEnabled())
{
log.warn(
"Tried to retrieve a localized string for a component that has not yet been added to the page. "
+ "This can sometimes lead to an invalid or no localized resource returned. "
+ "Make sure you are not calling Component#getString() inside your Component's constructor. "
+ "Offending component: {} - Resource key: {}", component, key);
}
}
String cacheKey = null;
String value;
// Make sure locale, style and variation have the right values
String variation = (component != null ? component.getVariation() : null);
if ((locale == null) && (component != null))
{
locale = component.getLocale();
}
if (locale == null)
{
locale = Session.exists() ? Session.get().getLocale() : Locale.getDefault();
}
if ((style == null) && (component != null))
{
style = component.getStyle();
}
if (style == null)
{
style = Session.exists() ? Session.get().getStyle() : null;
}
// If this component is not yet added to page we do not want to check
// cache as we can generate an invalid cache key
if ((cache != null) && ((component == null) || addedToPage))
{
cacheKey = getCacheKey(key, component, locale, style, variation);
}
// Value not found are cached as well (value = null)
if ((cacheKey != null) && cache.containsKey(cacheKey))
{
value = getFromCache(cacheKey);
if (log.isDebugEnabled())
{
log.debug("Property found in cache: '" + key + "'; Component: '" +
(component != null ? component.toString(false) : null) + "'; value: '" + value +
'\'');
}
}
else
{
if (log.isDebugEnabled())
{
log.debug("Locate property: key: '" + key + "'; Component: '" +
(component != null ? component.toString(false) : null) + '\'');
}
// Iterate over all registered string resource loaders until the property has been found
Iterator<IStringResourceLoader> iter = getStringResourceLoaders().iterator();
value = null;
while (iter.hasNext() && (value == null))
{
IStringResourceLoader loader = iter.next();
value = loader.loadStringResource(component, key, locale, style, variation);
}
// Cache the result incl null if not found
if (cacheKey != null)
{
putIntoCache(cacheKey, value);
}
if ((value == null) && log.isDebugEnabled())
{
log.debug("Property not found; key: '" + key + "'; Component: '" +
(component != null ? component.toString(false) : null) + '\'');
}
}
if (value == null)
{
value = defaultValue;
}
// If a property value has been found, or a default value was given,
// then replace the placeholder and we are done
if (value != null)
{
return substitutePropertyExpressions(component, value, model);
}
return null;
}