|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Inherited @Documented @Target(value=METHOD) @Retention(value=RUNTIME) public @interface EventHandler
This annotation may only be used in subclasses of Composite
that has been annotated with Templated
,
or in a super-class of said Composite
types.
Declares a method in a Templated
Composite
widget as a handler for standard Event
and
DomEvent
types fired by DataField
widgets and data-field
elements within the
Composite
component HTML template. Method handlers must accept a single argument of the type of event to be
handled.
The following scenarios are supported by this annotation:
WARNING: Native GWT events cannot be used in conjunction with GWT standard events, since upon addition to the
widget tree, GWT will override any Widget.sinkEvents(int)
that may have been configured by Errai UI.
GWT events on Widgets
Example:
@Templated public class WidgetHandlerComponent extends Composite { @Inject @DataField private Button button; @EventHandler("button") public void doSomethingC1(ClickEvent e) { // do something } }
GWT events on DOM Elements
Example:
@Templated public class WidgetHandlerComponent extends Composite { @Inject @DataField private DivElement button; @EventHandler("button") public void doSomethingC1(ClickEvent e) { // do something } }
Native events on DOM Elements
This approach requires use of the SinkNative
annotation, but does not require that target Element
instances be referenced via DataField
in the Templated
Composite
component; they may also
target un-referenced data-field
elements from the corresponding HTML template.
Example:
@Templated public class QuickHandlerComponent extends Composite { @DataField private AnchorElement link = DOM.createAnchor().cast(); @EventHandler("link") @SinkNative(Event.ONCLICK | Event.ONMOUSEOVER) public void doSomething(Event e) { // do something } @EventHandler("div") @SinkNative(Event.ONMOUSEOVER) public void doSomethingElse(Event e) { // do something with an element not otherwise referenced in our component } }
See also: SinkNative
, Templated
, DataField
Optional Element Summary | |
---|---|
String[] |
value
Specifies the element for which the corresponding event type should be be handled. |
public abstract String[] value
DataField
specified within the Templated
Composite
component (in the case of
handling GWT event types,) or a data-field
attribute in the corresponding HTML template (in the case
of handling native DOM events.)
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |