Class Action
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CallbackAction,PromiseAction,SetPropertyAction
Trigger fires.
Actions are the unit of behaviour you attach to a trigger: copy text to the
clipboard, download a file, scroll an element into view, and so on. Pair an
Action with a Trigger (typically via
trigger.triggers(action)) and the framework wires the action to run
whenever the trigger fires.
An Action usually consumes one or more inputs that supply its values — a literal, the current value of a DOM property, an event-scoped expression — so the data the action acts on is read on the client at fire time rather than captured on the server.
For Action implementors: override toJs(Trigger) to produce
the JavaScript that the trigger handler invokes; reference inputs through
Action.Input.toJs(Trigger) so the same value-supplier abstractions work with
every action.
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract JsFunctionBuilds theJsFunctionthat runs this action when the surrounding trigger fires.protected static voidwarnIfNotVisible(Component target, String actionDescription) Logs a warning iftargetis not visible.
-
Constructor Details
-
Action
public Action()
-
-
Method Details
-
toJs
Builds 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).- Parameters:
trigger- the surrounding trigger this render is for, notnull- Returns:
- the action's JS function, not
null
-
warnIfNotVisible
Logs a warning iftargetis not visible. Intended for actions that capture another component's element as a JsFunction reference: an invisible component is not sent to the client, the captured element reference resolves tonullwhen the install JS runs, and the action fails at fire time. JsFunction captures are bound by value at install time, so restoring visibility later does not recover the binding.Call this after the target is known to be attached (typically inside a
runWhenAttachedcallback) so the check sees the visibility state at the time the install JS would be sent to the client.- Parameters:
target- the component whose visibility to check, notnullactionDescription- human-readable name of the action being wired, used in the warning message (e.g."Fullscreen.enter()"), notnull
-