C - type of the component exported as a web componentP - type of the property exposed on the web componentpublic interface PropertyConfiguration<C extends Component,P extends Serializable> extends Serializable
WebComponentExporter.| 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.
|
PropertyConfiguration<C,P> onChange(SerializableBiConsumer<C,P> onChangeHandler)
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 is null for a property
type which should not receive null-values, such as double, the
method will be called with the property's default value. The default
value is set by WebComponentExporter
when addProperty(propertyName, defaultValue is called.
In the following example we export MyComponent as a web
component. The MyComponent class has a method setName
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);
}
}
onChangeHandler - component's method which is called with the property
valuePropertyConfigurationPropertyConfiguration<C,P> readOnly()
PropertyConfigurationCopyright © 2020. All rights reserved.