Class LiteComponent<COMPONENT extends Component>
java.lang.Object
com.vaadin.flow.component.Component
com.flowingcode.vaadin.addons.litetemplate.LiteComponent<COMPONENT>
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasStyle,Serializable
Wrapper around a
Component that provides fluent methods for managing attributes,
properties, and event listeners. It is designed for use in conjunction with the
LiteRenderer and cannot be used as a normal UI component.- Author:
- Javier Godoy
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidDisable interpolation of template properties within the attributes and properties of this component and its children.voidEnable interpolation of template properties within the attributes and properties of this component and its children.Unsupported operation.protected ComponentEventBusUnsupported operation.static <C extends Component>
LiteComponent<C>of(C component) Returns an instance ofLiteComponentfor the given component.unwrap()Returns the wrapped component.<SOURCE> LiteComponent<COMPONENT>withAttribute(String attribute, boolean value) Sets a boolean attribute on the component.<SOURCE> LiteComponent<COMPONENT>withAttribute(String attribute, ValueProvider<SOURCE, ?> valueProvider) Sets a dynamic attribute on the component.<SOURCE> LiteComponent<COMPONENT>withAttribute(String attribute, String value) Sets a string attribute on the component.<SOURCE> LiteComponent<COMPONENT>withElementProperty(String name, boolean value) Sets an element property to the given boolean value.<SOURCE> LiteComponent<COMPONENT>withElementProperty(String name, double value) Sets an element property to the given numeric value.<SOURCE> LiteComponent<COMPONENT>withElementProperty(String name, ValueProvider<SOURCE, ?> valueProvider) Sets a dynamic element property.<SOURCE> LiteComponent<COMPONENT>withElementProperty(String name, String value) Sets an element property to the given string value.<SOURCE> LiteComponent<COMPONENT>withElementPropertyBean(String name, Object value) Sets an element property to the given bean, converted to a JSON object.<SOURCE> LiteComponent<COMPONENT>withElementPropertyJson(String name, elemental.json.JsonValue value) Sets an element property to the given JSON value.<SOURCE> LiteComponent<COMPONENT>withElementPropertyList(String name, List<?> value) Sets an element property to the given list of beans or primitive values, converted to a JSON array.<SOURCE> LiteComponent<COMPONENT>withElementPropertyMap(String name, Map<String, ?> value) Sets an element property to the given map of beans or primitive values, converted to a JSON array.<SOURCE> LiteComponent<COMPONENT>withListener(String eventType, SerializableBiConsumer<SOURCE, elemental.json.JsonArray> handler, String... eventArguments) Registers an event listener for a DOM event on one of the child elements within the template component.<SOURCE> LiteComponent<COMPONENT>withListener(String eventType, SerializableConsumer<SOURCE> handler) Registers an event listener for a DOM event on one of the child elements within the template component.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Method Details
-
disableInterpolation
public void disableInterpolation()Disable interpolation of template properties within the attributes and properties of this component and its children.To enable interpolation on a particular child, use
enableInterpolation()on that child. -
enableInterpolation
public void enableInterpolation()Enable interpolation of template properties within the attributes and properties of this component and its children.To enable interpolation on a particular child, use
disableInterpolation()on that child. -
of
Returns an instance ofLiteComponentfor the given component. -
getElement
Unsupported operation.- Specified by:
getElementin interfaceHasElement- Overrides:
getElementin classComponent
-
getEventBus
Unsupported operation.- Overrides:
getEventBusin classComponent
-
unwrap
Returns the wrapped component. -
withAttribute
Sets a boolean attribute on the component.- Returns:
- this instance for method chaining
- See Also:
-
withAttribute
Sets a string attribute on the component.- Returns:
- this instance for method chaining
- See Also:
-
withAttribute
public <SOURCE> LiteComponent<COMPONENT> withAttribute(String attribute, ValueProvider<SOURCE, ?> valueProvider) Sets a dynamic attribute on the component. The value of the property is provided by aValueProviderand will be updated based on the input object.- Parameters:
attribute- the name of the attribute being bound. Must not benull.valueProvider- aValueProviderthat supplies the value of the attribute from the input object. Must not benull.- Returns:
- this instance for method chaining
- See Also:
-
withElementProperty
Sets an element property to the given boolean value.- Returns:
- this instance for method chaining
- See Also:
-
withElementProperty
Sets an element property to the given numeric value.- Returns:
- this instance for method chaining
- See Also:
-
withElementProperty
Sets an element property to the given string value.- Returns:
- this instance for method chaining
- See Also:
-
withElementPropertyBean
Sets an element property to the given bean, converted to a JSON object.- Returns:
- this instance for method chaining
- See Also:
-
withElementPropertyJson
public <SOURCE> LiteComponent<COMPONENT> withElementPropertyJson(String name, elemental.json.JsonValue value) Sets an element property to the given JSON value.- Returns:
- this instance for method chaining
- See Also:
-
withElementPropertyList
Sets an element property to the given list of beans or primitive values, converted to a JSON array.- Returns:
- this instance for method chaining
- See Also:
-
withElementPropertyMap
Sets an element property to the given map of beans or primitive values, converted to a JSON array.- Returns:
- this instance for method chaining
- See Also:
-
withElementProperty
public <SOURCE> LiteComponent<COMPONENT> withElementProperty(String name, ValueProvider<SOURCE, ?> valueProvider) Sets a dynamic element property. The value of the property is provided by aValueProviderand will be updated based on the input object.- Parameters:
name- the name of the property being bound. Must not benull.valueProvider- aValueProviderthat supplies the value of the property from the input object. Must not benull.- Returns:
- this instance for method chaining
- See Also:
-
withListener
public <SOURCE> LiteComponent<COMPONENT> withListener(String eventType, SerializableConsumer<SOURCE> handler) Registers an event listener for a DOM event on one of the child elements within the template component. Each DOM event can only be registered once per component.- Parameters:
eventType- The type of DOM event to listen for (e.g., "click", "change").handler- A callback function to handle the event when triggered- Returns:
- this instance for method chaining
- See Also:
-
withListener
public <SOURCE> LiteComponent<COMPONENT> withListener(String eventType, SerializableBiConsumer<SOURCE, elemental.json.JsonArray> handler, String... eventArguments) Registers an event listener for a DOM event on one of the child elements within the template component. Each DOM event can only be registered once per component. The function accepts arguments that can be consumed by the given handler.Example:
LiteRenderer.of(new TextField()) .withListener(child, "keypress", (item, args) -> { System.out.println("Pressed key: " + args.getString(0)); }, "e.key");- Parameters:
eventType- The type of DOM event to listen for (e.g., "click", "change").handler- A callback function to handle the event when triggeredeventArguments- One or more expressions for extracting event data. When an event is fired in the browser, the expression is evaluated and its value is sentback to the server. The expression is evaluated in a context where element refers to this element and event refersto the fired event. If multiple expressions are defined for the sameevent, their order of execution is undefined.- Returns:
- this instance for method chaining
- See Also:
-