Class CockpitComponentDefinitionLabelLocator
- java.lang.Object
-
- com.hybris.cockpitng.util.labels.CockpitComponentDefinitionLabelLocator
-
- All Implemented Interfaces:
org.zkoss.util.resource.LabelLocator2
public class CockpitComponentDefinitionLabelLocator extends java.lang.Object implements org.zkoss.util.resource.LabelLocator2Locates labels in the component definitions. These are located inlabels/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 keybutton.savedefined in the componentcom.simple.widgetwill be translated tocom.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}. Thelabelsmap 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
WidgetInstanceManagerbe injected in your controller class and useWidgetInstanceManager.getLabel(String)orWidgetInstanceManager.getLabel(String, Object[])to get the label. Use the localization key as specified in the properties file, e.g."button.save". If you use theDefaultWidgetControlleras the superclass of your widget controller class you can call directlyDefaultWidgetController.getLabel(String)orDefaultWidgetController.getLabel(String, Object[]).
-
-
Constructor Summary
Constructors Constructor Description CockpitComponentDefinitionLabelLocator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCharset()static java.lang.StringgetLabel(java.util.Map<java.lang.String,java.lang.Object> labelMap, java.lang.String key)static java.lang.StringgetLabel(java.util.Map<java.lang.String,java.lang.Object> labelMap, java.lang.String key, java.lang.Object[] args)static java.util.Map<java.lang.String,java.lang.Object>getLabelMap(AbstractCockpitComponentDefinition definition)voidinit()java.io.InputStreamlocate(java.util.Locale locale)Locates labels for all widget definitions in the system.voidsetComponentDefinitionService(CockpitComponentDefinitionService componentDefinitionService)
-
-
-
Method Detail
-
getLabelMap
public static java.util.Map<java.lang.String,java.lang.Object> getLabelMap(AbstractCockpitComponentDefinition definition)
-
getLabel
public static java.lang.String getLabel(java.util.Map<java.lang.String,java.lang.Object> labelMap, java.lang.String key)
-
getLabel
public static java.lang.String getLabel(java.util.Map<java.lang.String,java.lang.Object> labelMap, java.lang.String key, java.lang.Object[] args)
-
locate
public java.io.InputStream locate(java.util.Locale locale)
Locates labels for all widget definitions in the system.- Specified by:
locatein interfaceorg.zkoss.util.resource.LabelLocator2
-
getCharset
public java.lang.String getCharset()
- Specified by:
getCharsetin interfaceorg.zkoss.util.resource.LabelLocator2
-
init
public void init()
-
setComponentDefinitionService
public void setComponentDefinitionService(CockpitComponentDefinitionService componentDefinitionService)
-
-