4.17. Custom Composite Components

The ease of making custom user interface components is one of the core features of IT Mill Toolkit. Custom components can be created at several levels. Typically, you simply combine existing built-in components to produce composite components. In many applications, such composite components make up the majority of the user interface. You can also create your own low-level components, for example existing GWT components. It is also possible to extend the functionality of existing components.

The architecture of user interface components is described in Chapter 4, User Interface Components. For more information about the overall architecture of IT Mill Toolkit, please see Chapter 2, Architecture. Use of custom GWT components is covered in Chapter 8, Developing Custom Components.

The easiest way of creating new components is combining existing components. This can be done in two basic ways: inheritance and management. With inheritance, you inherit some containing class, typically CustomComponent or some abstract class such as AbstractComponent, AbstractField, or AbstractComponentContainer. With management, you create a class that creates the needed components under some layout and handles their events. Both of these patterns are used extensively in the examples in Chapter 4, User Interface Components and elsewhere.

4.17.1. CustomComponent

The CustomComponent class is a simple implementation of the Component interface that provides a simple way for creating new user interface components by the composition of existing components.

Composition is done by inheriting the CustomComponent class and setting the composite root inside the component with setCompositionRoot(). The composite root is typically a layout component that contains multiple components.