Class SetPropertyAction<T>
java.lang.Object
com.vaadin.flow.component.trigger.internal.Action
com.vaadin.flow.component.trigger.internal.SetPropertyAction<T>
- Type Parameters:
T- the runtime type of the value to assign
- All Implemented Interfaces:
Serializable
Assigns a value to a JavaScript property on a target element when the bound
trigger fires. Pure client-side — no server round-trip.
Symmetric with PropertyInput: the same property name space
(DOM/custom-element properties such as value, checked,
disabled).
The value to assign can be either a literal (constant, serialised at build
time) or an Action.Input that produces the value on the client when
the trigger fires — for example, MouseEventTrigger.EventData.screenX
feeds the click's screen coordinate.
Common idioms:
- Disable a button:
new SetPropertyAction(button, "disabled", true) - Clear an input:
new SetPropertyAction(input, "value", "") - Mirror a click coordinate:
new SetPropertyAction(field, "value", ClickTrigger.EventData.screenX)
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.trigger.internal.Action
Action.Input<T> -
Constructor Summary
ConstructorsConstructorDescriptionSetPropertyAction(Component target, String propertyName, @Nullable T value) Creates an action that assigns the given literal value to the given JS property ontargetwhen the trigger fires.SetPropertyAction(Component target, String propertyName, Action.Input<? extends T> source) Creates an action that assigns the value produced bysourceto the given JS property ontargetwhen the trigger fires. -
Method Summary
Modifier and TypeMethodDescriptionprotected JsFunctionBuilds theJsFunctionthat runs this action when the surrounding trigger fires.Methods inherited from class com.vaadin.flow.component.trigger.internal.Action
warnIfNotVisible
-
Constructor Details
-
SetPropertyAction
Creates an action that assigns the given literal value to the given JS property ontargetwhen the trigger fires. Passingnullclears the property (renderstarget[prop] = null;).- Parameters:
target- the component whose root element to modify, notnullpropertyName- the JS property name, notnullvalue- the value to assign —String,Boolean,Number, or any Jackson-serialisable object; may benullto emit a JSnull(e.g. to clear an input's value)
-
SetPropertyAction
Creates an action that assigns the value produced bysourceto the given JS property ontargetwhen the trigger fires.- Parameters:
target- the component whose root element to modify, notnullpropertyName- the JS property name, notnullsource- input that produces the value to assign, notnull
-
-
Method Details
-
toJs
Description copied from class:ActionBuilds theJsFunctionthat runs this action when the surrounding trigger fires. The returned function takes one runtime argument namedevent(declared by the framework when it composes the trigger handler); subclasses do not declare argument names themselves.The body is one statement. To embed a value produced on the client, capture an
Action.Input'sJsFunctionas a capture and invoke it inside the body as$N(event).
-