C
- type of the exported component
P
- type of the propertypublic final class PropertyConfigurationImpl<C extends Component,P extends Serializable> extends Object implements PropertyConfiguration<C,P>
Constructor and Description |
---|
PropertyConfigurationImpl(Class<C> componentType,
String propertyName,
Class<P> propertyType,
P defaultValue)
Constructs a new
PropertyConfigurationImpl tied to the exported
Component type given by componentType . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
SerializableBiConsumer<C,Serializable> |
getOnChangeHandler()
Retrieves the
onChangeHandler tied to this property, if one
exists. |
PropertyData<P> |
getPropertyData()
Computed
PropertyData based on the configuration details. |
int |
hashCode() |
PropertyConfiguration<C,P> |
onChange(SerializableBiConsumer<C,P> onChangeHandler)
Sets a Property change handler.
|
PropertyConfiguration<C,P> |
readOnly()
Mark the property as read-only.
|
public PropertyConfigurationImpl(Class<C> componentType, String propertyName, Class<P> propertyType, P defaultValue)
PropertyConfigurationImpl
tied to the exported
Component
type given by componentType
.componentType
- type of the exported component
propertyName
- name of the propertypropertyType
- type of the propertydefaultValue
- default value of the property. If the property type has a
primitive version, this value is used when ever the property
is being set to a null
.public PropertyConfiguration<C,P> onChange(SerializableBiConsumer<C,P> onChangeHandler)
PropertyConfiguration
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); } }
onChange
in interface PropertyConfiguration<C extends Component,P extends Serializable>
onChangeHandler
- component
's method which is called with the property
valuePropertyConfiguration
public PropertyConfiguration<C,P> readOnly()
PropertyConfiguration
readOnly
in interface PropertyConfiguration<C extends Component,P extends Serializable>
PropertyConfiguration
public SerializableBiConsumer<C,Serializable> getOnChangeHandler()
onChangeHandler
tied to this property, if one
exists.null
public PropertyData<P> getPropertyData()
PropertyData
based on the configuration details.PropertyData
value objectCopyright © 2025. All rights reserved.