BindingContext bindingContext = new BindingContext();
Div div = new Div();
UiCreator
.createUiElements(new PartnerSectionPmo(new Partner()), bindingContext,
c -> new LabelComponentWrapper((Component)c, WrapperType.FIELD))
.map(LabelComponentWrapper::getComponent)
.forEach(div::add);
Creation of a UI with linkki
Create individual components
Instead of creating the layout using layout annotations, it is also possible to only create the UI elements that are defined in a PMO by using UiCreator
.
In the following example, the UI elements of a PMO are directly added to a Vaadin Div
. In this case, the possibly existing annotation of the PMO class is ignored, only annotations on methods are respected.
If the layout is as simple as in this example it would be much more convenient to write a custom layout annotation. Only use this approach to get more control over special cases of the layout. |
Filtering of Components
When using the UiCreator
you can choose to create all UI elements from a PMO object (via the createUiElements(Object, BindingContext, Function<C, W>)
method) or choose the elements you want to display yourself, for example by reading additional annotations (like @SectionHeader
), by way of the method createUiElement(AnnotatedElement, Object, BindingContext, Function<C, W>)
which takes a single annotated element as an additional argument and creates only the UI elements from that annotated element. You can obtain all annotated elements from ComponentAnnotationReader#getComponentDefinitionMethods(Class<?>)
.