public class CockpitComponentDefinitionLabelLocator extends Object implements org.zkoss.util.resource.LabelLocator2
labels/labels_*.properties (relative
to the root of the definition).
All label keys are processed and equipped with a prefix which is the component definition code and the '.' character.
For example the localization key button.save defined in the component com.simple.widget
will be translated to com.simple.widget.button.save. This is then passed to the ZK label engine.
However, in a widget view you can access its labels without specifying the prefix like this:
${labels.button.save}. The labels map is prepared to contain widget specific labels only
and in the widget specific name space.
In the widget controller you can access the labels in an easy way as well. Let the WidgetInstanceManager be
injected in your controller class and use WidgetInstanceManager.getLabel(String) or
WidgetInstanceManager.getLabel(String, Object[]) to get the label. Use the localization key as specified in
the properties file, e.g. "button.save". If you use the DefaultWidgetController as the
superclass of your widget controller class you can call directly DefaultWidgetController.getLabel(String) or
DefaultWidgetController.getLabel(String, Object[]).
| Constructor and Description |
|---|
CockpitComponentDefinitionLabelLocator() |
| Modifier and Type | Method and Description |
|---|---|
String |
getCharset() |
static String |
getLabel(Map<String,Object> labelMap,
String key) |
static String |
getLabel(Map<String,Object> labelMap,
String key,
Object[] args) |
static Map<String,Object> |
getLabelMap(AbstractCockpitComponentDefinition definition) |
void |
init() |
InputStream |
locate(Locale locale)
Locates labels for all widget definitions in the system.
|
void |
setComponentDefinitionService(CockpitComponentDefinitionService componentDefinitionService) |
public CockpitComponentDefinitionLabelLocator()
public static Map<String,Object> getLabelMap(AbstractCockpitComponentDefinition definition)
public InputStream locate(Locale locale)
locate in interface org.zkoss.util.resource.LabelLocator2public String getCharset()
getCharset in interface org.zkoss.util.resource.LabelLocator2public void init()
public void setComponentDefinitionService(CockpitComponentDefinitionService componentDefinitionService)
Copyright © 2018. All rights reserved.