Class CockpitComponentDefinitionLabelLocator

  • All Implemented Interfaces:
    org.zkoss.util.resource.LabelLocator2

    public class CockpitComponentDefinitionLabelLocator
    extends java.lang.Object
    implements org.zkoss.util.resource.LabelLocator2
    Locates labels in the component definitions. These are located in 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 Detail

      • CockpitComponentDefinitionLabelLocator

        public CockpitComponentDefinitionLabelLocator()
    • Method Detail

      • 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:
        locate in interface org.zkoss.util.resource.LabelLocator2
      • getCharset

        public java.lang.String getCharset()
        Specified by:
        getCharset in interface org.zkoss.util.resource.LabelLocator2
      • init

        public void init()