Class AbstractEventSignal
- Direct Known Subclasses:
AbstractJSignal
,EventSignal
,EventSignal1
Event signals are signals that may be triggered from the browser. Listeners that are added to this signal may be implemented in Java only or in JavaScript only or have both Java and JavaScript implementations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A listener whose JavaScript behavior is learned on its first invocation.static class
A JavaScript-only listener.static class
An abstract base class for a listener with (learned) JavaScript behavior.static class
A listener whose JavaScript behavior is learned in advance.Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractSignal
AbstractSignal.Connection
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(JSlot slot) Adds a JavaScript event listener.void
addListener
(WObject listenerOwner, AbstractEventSignal.AutoLearnListener listener) Adds a learning listener to this signal.void
addListener
(WObject listenerOwner, AbstractEventSignal.JavaScriptListener listener) Adds a learning listener to this signal.void
addListener
(WObject listenerOwner, AbstractEventSignal.LearningListener listener) Adds a learning listener to this signal.void
addListener
(WObject listenerOwner, AbstractEventSignal.PreLearnListener listener) Adds a learning listener to this signal.void
addListener
(String javascript) Adds a JavaScript event listener.protected String
createUserEventCall
(String jsObject, String jsEvent, String name, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6) void
disconnect
(AbstractSignal.Connection connection) protected int
Returns the number of connected listeners.boolean
boolean
Returns whether at least one event listener has been connected to this signal.boolean
Returns whether propagation of the event is prevented.boolean
Returns whether the default action is prevented.void
Prevents the default action associated with this event.void
preventDefaultAction
(boolean prevent) Prevents the default action associated with this event.final void
Prevents the default action associated with this event.void
preventPropagation
(boolean prevent) Prevents the default action associated with this event.void
Remove a learning listener from this signal.void
removeListener
(JSlot listener) Remove a JavaScript listener from this signal.Methods inherited from class eu.webtoolkit.jwt.AbstractSignal
addListener, getArgumentCount, getListeners, isBlocked, removeListener, setBlocked
-
Method Details
-
addListener
Adds a learning listener to this signal.An owner object may be passed when the listener is implemented using an anonymous inner class. In that case the owner object should be the enclosing object of the listener object, and this is used to bind the lifetime of the listener: when the owner object is garbage collected, the listener will be freed as well. This avoids the most common reason for memory leaks in Java implementations of the Observer pattern: the owner object will not get garbage collected because of the (anonymous) listener object having a reference to it, even if the receiver object is no longer referenced from anywhere. When the owner object is not
null
, the listener is stored using a strong reference in the owner object, and using a weak reference in the signal. Note: The receiver is currently not yet used.- Parameters:
listenerOwner
- if notnull
, the enclosing object for an anonymous listenerlistener
- the listener
-
addListener
Adds a learning listener to this signal.- See Also:
-
addListener
Adds a learning listener to this signal.- See Also:
-
addListener
Adds a learning listener to this signal.- See Also:
-
removeListener
Remove a learning listener from this signal.- Parameters:
listener
- a learning listener that was previously added
-
removeListener
Remove a JavaScript listener from this signal.- Parameters:
listener
- a learning listener that was previously added
-
getListenerCount
protected int getListenerCount()Description copied from class:AbstractSignal
Returns the number of connected listeners.- Overrides:
getListenerCount
in classAbstractSignal
- Returns:
- the number of connected listeners.
-
isCanAutoLearn
public boolean isCanAutoLearn() -
isConnected
public boolean isConnected()Description copied from class:AbstractSignal
Returns whether at least one event listener has been connected to this signal.- Overrides:
isConnected
in classAbstractSignal
- Returns:
- whether at least one event listener has been connected to this signal.
-
isPropagationPrevented
public boolean isPropagationPrevented()Returns whether the default action is prevented.- Returns:
- whether the default action is prevented.
- See Also:
-
isDefaultActionPrevented
public boolean isDefaultActionPrevented()Returns whether propagation of the event is prevented.- Returns:
- whether the default action is prevented.
- See Also:
-
addListener
Adds a JavaScript event listener.- Parameters:
slot
- the JavaScript event listener
-
addListener
Adds a JavaScript event listener. This adds a listener that is implemented solely as a client-side JavaScript function. The argument is a JavaScript function which optionally accepts a DOM element and the event:function(element, event) { ... }
- Parameters:
javascript
- the JavaScript function.
-
preventDefaultAction
public void preventDefaultAction(boolean prevent) Prevents the default action associated with this event.This prevents the default browser action associated with this event.
- Parameters:
prevent
- whether the default action should be prevented.
-
preventDefaultAction
public void preventDefaultAction()Prevents the default action associated with this event.This prevents the default browser action associated with this event.
-
preventPropagation
public void preventPropagation(boolean prevent) Prevents the default action associated with this event.This prevents the event propagation to ancestors.
- Parameters:
prevent
- whether the default action should be prevented.
-
preventPropagation
public final void preventPropagation()Prevents the default action associated with this event.This prevents both the default browser action associated with this event as well as the event bubbling up or cascading its hierarchy.
-
disconnect
-
createUserEventCall
-