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:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCockpitEventAcceptor(CockpitEventAcceptor acceptor) Registers theCockpitEventAcceptoracceptor with this widget container.voidcleanup()Performs widget cleanup i.e.voidfocusWidget(String widgetCode) Focuses the widget associated with the specified widget code.Returns the widget code of the currently focused widget.Returns the widget associated with the specified widget code.Returns theWidgetFactoryused for creating widgets.initialize(Map<String, WidgetConfig> widgetMap) Initializes this container i.e.voidUnregisters theCockpitEventAcceptoracceptor with this widget container.voidsetWidgetFactory(WidgetFactory widgetFactory) Sets theWidgetFactoryused for creating widgets.
-
Method Details
-
initialize
Initializes this container i.e. creates widgets based on the suppliedWidgetConfigmap.- 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
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
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
Focuses the widget associated with the specified widget code.- Parameters:
widgetCode- widget code
-
setWidgetFactory
Sets theWidgetFactoryused for creating widgets.- Parameters:
widgetFactory- the widget factory
-
getWidgetFactory
WidgetFactory getWidgetFactory()Returns theWidgetFactoryused for creating widgets.- Returns:
- the widget factory
-
addCockpitEventAcceptor
Registers theCockpitEventAcceptoracceptor with this widget container.- Parameters:
acceptor- the event acceptor to register
-
removeCockpitEventAcceptor
Unregisters theCockpitEventAcceptoracceptor with this widget container.- Parameters:
acceptor- the event acceptor to unregister
-