com.vaadin.flow.component.webcomponent.
Interface PropertyConfiguration<C extends Component,P extends Serializable>
-
Type Parameters:
C
- type of thecomponent
exported as a web componentP
- type of the property exposed on the web componentAll Superinterfaces:
All Known Implementing Classes:
public interface PropertyConfiguration<C extends Component,P extends Serializable> extends Serializable
Offers a fluent API for configuring the properties of embedded web components produced by
WebComponentExporter
.Since:
2.0
Author:
Vaadin Ltd.
-
-
Method Summary
All Methods Modifier and Type Method and Description PropertyConfiguration<C,P>
onChange(SerializableBiConsumer<C,P> onChangeHandler)
Sets a Property change handler.
PropertyConfiguration<C,P>
readOnly()
Mark the property as read-only.
-
-
-
Method Detail
-
onChange
PropertyConfiguration<C,P> onChange(SerializableBiConsumer<C,P> onChangeHandler)
Sets a Property change handler.
onChange
can only be called once - multiple calls will throw an exception.The
onChangeHandler
is called when the property's value changes on the client-side. If the property value isnull
for a property type which should not receive null-values, such asdouble
, the method will be called with the property's default value. The default value is set byWebComponentExporter
whenaddProperty(propertyName, defaultValue
is called.In the following example we export
MyComponent
as a web component. TheMyComponent
class has a methodsetName
which will be called in response to changes to the registered property"name"
.@Tag("my-component") public class Exporter implements WebComponentExporter<MyComponent>() { // ... define the web component public Exporter() { super("my-component"); addProperty("name", "John Doe").onChange(MyComponent::setName); } }
Parameters:
onChangeHandler
-component
's method which is called with the property valueReturns:
this
PropertyConfiguration
-
readOnly
PropertyConfiguration<C,P> readOnly()
Mark the property as read-only. It cannot be written to by the client.
Returns:
this
PropertyConfiguration
-
-