Generic Component XML
The component XML element enables you to create any UI component by specifying its fully qualified class name (FQN). Component properties are defined using nested property elements, similar to action configuration.
For example, you can define a Button component this way:
<component id="button" class="com.vaadin.flow.component.button.Button">
<properties>
<property name="text" value="Button"/>
<property name="icon" value="PLUS" type="ICON"/>
</properties>
</component>
Here is an example of defining a custom component:
<component id="testComponent" class="com.company.onboarding.component.TestComponent">
<properties>
<property name="text" value="Button"/>
<property name="stringsList" value="a b ,c"/>
<property name="stringsSet" value="a b ,c"/>
<property name="stringsArray" value="a b ,c"/>
<property name="strings" value="a b ,c"/>
<property name="dataContainer" value="productsDc" type="CONTAINER_REF"/>
</properties>
</component>
Property Configuration
-
The
nameattribute value is converted to a setter method name, for example:-
text→setText() -
dataLoader→setDataLoader()
-
-
The framework searches for the first method with the matching
nameand a single input parameter to set the value.If multiple methods share the same name, there is no guarantee that the intended one will be used to set the value. -
The found method’s input parameter type is used to convert the string value from the
valueattribute into the actual value. -
The
typeattribute indicates that string value must be converted by one of the pluggablePropertyParserbeans:Type Parser Description ICONIconPropertyParserConverts a string to an
IconinstanceCONTAINER_REFDataContainerPropertyParserResolves a data container by
IDLOADER_REFDataLoaderPropertyParserResolves a data loader by
ID
Property Parsers
When string values cannot be directly converted using the parameter type, pluggable PropertyParser beans handle the transformation.
Currently, there are three implementations:
-
IconPropertyParser. Converts strings to
Iconinstances.-
If the passed string contains
:delimiter, a newIconis created using the icon collection and icon name values. -
Otherwise, the string is treated as a
VaadinIconconstant name.Examples:
-
"PLUS"→VaadinIcon.PLUSicon. -
"myicons:custom"→ Icon from the custom collection"myicons"with the name"custom".
-
-
DataContainerPropertyParser. Returns a data container with the given
IDfrom the corresponding view’sViewDataobject. -
DataLoaderPropertyParser. Returns a data loader with the given
IDfrom the corresponding view’sViewDataobject.