Interface WidgetContainer<T extends Widget>

  • All Known Implementing Classes:
    DefaultWidgetContainer, PortalWidgetContainer

    public interface WidgetContainer<T extends Widget>
    A WidgetContainer is used to group widgets together. It provides functionality for creating widgets (see initialize(Map)) as well as managing widget focus and cleanup process.

    Example: Creating and loading a Widget.

      // widget creation map
      Map<String, WidgetConfig> widgetCreationMap = new HashMap<String, Widget>();

      // widget 1
      final String widgetCode1 = "widget1"; // code of the soon-to-be-created widget
      final WidgetConfig widgetConfig1 = // ... get widget config somehow e.g. load bean from Spring context
      widgetCreationMap.put(widgetCode1, widgetConfig1); // add to map

      // widget 2
      final String widgetCode2 = "widget2";
      final WidgetConfig widgetConfig2 = // ...
      widgetCreationMap.put(widgetCode2, widgetConfig2);

      // create widgets
      final Map<String, Widget> widgetMap = widgetContainer.initialize(widgetMap);
    See Also:
    WidgetConfig, Widget, WidgetFactory
    • Method Detail

      • initialize

        java.util.Map<java.lang.String,​T> initialize​(java.util.Map<java.lang.String,​WidgetConfig> widgetMap)
        Initializes this container i.e. creates widgets based on the supplied WidgetConfig map.
        Parameters:
        widgetMap - map containing widget codes and configurations used when creating the widgets
        Returns:
        map containing the created widgets mapped to their widget code
      • cleanup

        void cleanup()
        Performs widget cleanup i.e. unregisters any listeners etc.

        Note: It is very important that this method is called when the widgets are invalidated e.g. when the widgets' parent view component has been detached from the ZK desktop.

      • getWidget

        T getWidget​(java.lang.String widgetCode)
        Returns the widget associated with the specified widget code.
        Parameters:
        widgetCode - widget code
        Returns:
        widget mapped to the code or null if no widget is mapped to the supplied key
      • getFocusedWidgetCode

        java.lang.String getFocusedWidgetCode()
        Returns the widget code of the currently focused widget.
        Returns:
        code of the focused widget or null if no widget has focus
      • focusWidget

        void focusWidget​(java.lang.String widgetCode)
        Focuses the widget associated with the specified widget code.
        Parameters:
        widgetCode - widget code
      • setWidgetFactory

        void setWidgetFactory​(WidgetFactory widgetFactory)
        Sets the WidgetFactory used for creating widgets.
        Parameters:
        widgetFactory - the widget factory
      • getWidgetFactory

        WidgetFactory getWidgetFactory()
        Returns the WidgetFactory used for creating widgets.
        Returns:
        the widget factory
      • addCockpitEventAcceptor

        void addCockpitEventAcceptor​(CockpitEventAcceptor acceptor)
        Registers the CockpitEventAcceptor acceptor with this widget container.
        Parameters:
        acceptor - the event acceptor to register
      • removeCockpitEventAcceptor

        void removeCockpitEventAcceptor​(CockpitEventAcceptor acceptor)
        Unregisters the CockpitEventAcceptor acceptor with this widget container.
        Parameters:
        acceptor - the event acceptor to unregister