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

public class SetPropertyAction<T> extends Action
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, click.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", click.screenX())
Server-side state is not updated by this action; the change lives in the browser until the next sync from the client (if any).

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Details

    • SetPropertyAction

      public SetPropertyAction(Component target, String propertyName, @Nullable T value)
      Creates an action that assigns the given literal value to the given JS property on target when the trigger fires.
      Parameters:
      target - the component whose root element to modify, not null
      propertyName - the JS property name, not null
      value - the value to assign — String, Boolean, Number, or any Jackson-serialisable object; may be null
    • SetPropertyAction

      public SetPropertyAction(Component target, String propertyName, Action.Input<? extends T> source)
      Creates an action that assigns the value produced by source to the given JS property on target when the trigger fires.
      Parameters:
      target - the component whose root element to modify, not null
      propertyName - the JS property name, not null
      source - input that produces the value to assign, not null
  • Method Details

    • appendStatement

      protected void appendStatement(com.vaadin.flow.component.trigger.internal.JsBuilder builder, StringBuilder out)
      Description copied from class: Action
      Appends this action's JS statement to out. Element references must go through JsBuilder.reference(com.vaadin.flow.dom.Element).
      Specified by:
      appendStatement in class Action
      Parameters:
      builder - collects element parameter references, not null
      out - buffer to append into, not null