Class JSignal6<A1,A2,A3,A4,A5,A6>
public abstract class JSignal6<A1,A2,A3,A4,A5,A6> extends AbstractJSignal
The argument types A1 to A6 must be a String, WString or a wrapper class
of one of the Java primitive types. Values of the corresponding JavaScript types can be
passed to the JavaScript call.
Note that this is an abstract class. To create a JSignal, you should specialize this class, but you do not need to reimplement any method. The reason for this is to circumvent limitations in Java to obtain introspection in the types of the arguments, and provide suitable marshaling of data from JavaScript to Java. The easiest way to instantiate an object of this class is:
JSignal6<String, Integer, Double, Integer, WString, Integer> pingSignal
= new JSignal6<String, Integer, Double, Integer, WString, Integer>(this, "pingSignal") { };
For a usage example take a look the documentation of JSignal2.-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractEventSignal
AbstractEventSignal.AutoLearnListener, AbstractEventSignal.JavaScriptListener, AbstractEventSignal.LearningListener, AbstractEventSignal.PreLearnListenerNested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractSignal
AbstractSignal.Connection -
Constructor Summary
-
Method Summary
Modifier and Type Method Description AbstractSignal.ConnectionaddListener(WObject listenerOwner, Signal.Listener listener)Adds a listener for this signal.AbstractSignal.ConnectionaddListener(WObject listenerOwner, Signal6.Listener<A1,A2,A3,A4,A5,A6> listener)Adds a listener for this signal.java.lang.StringcreateCall(java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5)java.lang.StringcreateCall(java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5, java.lang.String arg6)Returns a JavaScript statement that triggers this signal.java.lang.StringcreateEventCall(java.lang.String jsObject, java.lang.String jsEvent, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5)protected intgetArgumentCount()Returns the number of parameters (excluding an 'event').protected intgetListenerCount()Returns the number of connected listeners.voidremoveListener(Signal.Listener listener)Removes a listener.voidremoveListener(Signal6.Listener<A1,A2,A3,A4,A5,A6> listener)Removes a listener.voidtrigger(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)Triggers the signal.Methods inherited from class eu.webtoolkit.jwt.AbstractJSignal
createUserEventCall, getNameMethods inherited from class eu.webtoolkit.jwt.AbstractEventSignal
addListener, addListener, addListener, addListener, addListener, addListener, createUserEventCall, disconnect, isCanAutoLearn, isConnected, isDefaultActionPrevented, isPropagationPrevented, preventDefaultAction, preventDefaultAction, preventPropagation, preventPropagation, removeListener, removeListenerMethods inherited from class eu.webtoolkit.jwt.AbstractSignal
getListeners, isBlocked, setBlockedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JSignal6
Creates a signal.- Parameters:
sender- the object that will be identified as the sender for this signal.name- the signal name (must be unique for each sender)
-
-
Method Details
-
addListener
public AbstractSignal.Connection addListener(WObject listenerOwner, Signal6.Listener<A1,A2,A3,A4,A5,A6> listener)Adds a listener for this signal.Each listener will be triggered whenever the signal is triggered.
- Parameters:
listenerOwner- the enclosing object for a listener implemented using an (anonymous) inner classlistener- the listener- Returns:
- a connection object that may be used to control the connection
- See Also:
AbstractSignal.addListener(WObject, eu.webtoolkit.jwt.Signal.Listener)
-
getListenerCount
protected int getListenerCount()Description copied from class:AbstractSignalReturns the number of connected listeners.- Overrides:
getListenerCountin classAbstractEventSignal- Returns:
- the number of connected listeners.
-
removeListener
Removes a listener.- Parameters:
listener- a listener that was previously added
-
trigger
Triggers the signal.The arguments are passed to the listeners.
- Parameters:
arg1- Argument 1arg2- Argument 2arg3- Argument 3arg4- Argument 4arg5- Argument 5
-
createEventCall
public java.lang.String createEventCall(java.lang.String jsObject, java.lang.String jsEvent, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5) -
createCall
public java.lang.String createCall(java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5, java.lang.String arg6)Returns a JavaScript statement that triggers this signal.You can use this to trigger the signal from within generated JavaScript code.
- Parameters:
arg1- JavaScript argument 1.arg2- JavaScript argument 2.arg3- JavaScript argument 3.arg4- JavaScript argument 4.arg5- JavaScript argument 5.arg6- JavaScript argument 6.
-
createCall
public java.lang.String createCall(java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4, java.lang.String arg5) -
addListener
Description copied from class:AbstractSignalAdds a listener for this signal.Each listener will be notified when the signal is triggered.
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. To avoid the owner object from not being garbage collected when it is no longer used, only the owner object will add a reference to the listener, while the signal will use a weak reference.
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.- Specified by:
addListenerin classAbstractSignal- Parameters:
listenerOwner- if notnull, the enclosing object for a listener implemented using an inner classlistener- the listener- Returns:
- a connection object that may be used to control the connection
-
removeListener
Description copied from class:AbstractSignalRemoves a listener.- Specified by:
removeListenerin classAbstractSignal- Parameters:
listener- a listener that was previously added.
-
getArgumentCount
protected int getArgumentCount()Description copied from class:AbstractSignalReturns the number of parameters (excluding an 'event').- Specified by:
getArgumentCountin classAbstractSignal
-