public class Events
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ON_AFTER_SIZE
The onAfterSize event (used with
AfterSizeEvent ). |
static java.lang.String |
ON_BLUR
The onBlur event (used with
Event ). |
static java.lang.String |
ON_BOOKMARK_CHANGE
The onBookmarkChange event (used with
BookmarkEvent )
to notify that user pressed BACK, FORWARD or specified URL directly
that causes the bookmark is changed (but still in the same desktop). |
static java.lang.String |
ON_CANCEL
The onCancel event (used with
KeyEvent ). |
static java.lang.String |
ON_CHANGE
The onChange event (used with
InputEvent ). |
static java.lang.String |
ON_CHANGING
The onChanging event (used with
InputEvent ). |
static java.lang.String |
ON_CHECK
The onCheck event (used with
CheckEvent ). |
static java.lang.String |
ON_CLICK
The onClick event (used with
MouseEvent ). |
static java.lang.String |
ON_CLIENT_INFO
The onClientInfo event (used with
ClientInfoEvent ). |
static java.lang.String |
ON_CLOSE
The onClose event (used with
Event )
used to denote the close button is pressed. |
static java.lang.String |
ON_CREATE
The onCreate event (used with
CreateEvent ) to notify a component
that it (and its children) has been created by ZK's evaluating a ZUML page. |
static java.lang.String |
ON_CTRL_KEY
The onCtrlKey event (used with
KeyEvent ). |
static java.lang.String |
ON_DEFERRED_EVALUATION
The onDeferredEvaluation event (used with
Event )
to notify a component the Composer.doAfterCompose(Component) phase is done,
and can evaluate deferred expressions if any. |
static java.lang.String |
ON_DESKTOP_RECYCLE
The onDesktopRecycle event (used with
Event )
to notify that a desktop has been recycled. |
static java.lang.String |
ON_DOUBLE_CLICK
The onDoubleClick event (used with
MouseEvent ). |
static java.lang.String |
ON_DROP
The onDrop event (used with
DropEvent ). |
static java.lang.String |
ON_ERROR
The onError event (used with
ErrorEvent ). |
static java.lang.String |
ON_FOCUS
The onFocus event (used with
Event ). |
static java.lang.String |
ON_FULFILL
The onFulfill event (used with
FulfillEvent )
to denote a fulfill condition has been applied. |
static java.lang.String |
ON_GROUP
The onGroup event (used with
Event )
to notify a request for grouping. |
static java.lang.String |
ON_HISTORY_POP_STATE
The onHistoryPopState event (used with
HistoryPopStateEvent ). |
static java.lang.String |
ON_MAXIMIZE
The onMaximize event (used with
MaximizeEvent ). |
static java.lang.String |
ON_MINIMIZE
The onMinimize event (used with
MinimizeEvent ). |
static java.lang.String |
ON_MODAL
The onModal event (used with
Event ) to notify a component
shall become modal. |
static java.lang.String |
ON_MOUSE_OUT
The onMouseOut event (used with
MouseEvent ). |
static java.lang.String |
ON_MOUSE_OVER
The onMouseOver event (used with
MouseEvent ). |
static java.lang.String |
ON_MOVE
The onMove event (used with
MoveEvent ). |
static java.lang.String |
ON_NOTIFY
The onNotify event (used with
Event ). |
static java.lang.String |
ON_OK
The onOK event (used with
KeyEvent ). |
static java.lang.String |
ON_OPEN
The onOpen event (used with
OpenEvent ). |
static java.lang.String |
ON_PIGGYBACK
The onPiggyback event (used with
Event ) used to notify
a root component that the client has sent a request to the server. |
static java.lang.String |
ON_RENDER
The onRender request.
|
static java.lang.String |
ON_RIGHT_CLICK
The onRightClick event (used with
MouseEvent ). |
static java.lang.String |
ON_SCRIPT_ERROR
The onScriptError event used with
ScriptErrorEvent . |
static java.lang.String |
ON_SCROLL
The onScroll event (used with
ScrollEvent ). |
static java.lang.String |
ON_SCROLLING
The onScrolling event (used with
ScrollEvent ). |
static java.lang.String |
ON_SEARCHING
The onSearching event (used with
InputEvent ). |
static java.lang.String |
ON_SELECT
The onSelect event (used with
SelectEvent ). |
static java.lang.String |
ON_SELECTION
The onSelection event (used with
SelectionEvent ). |
static java.lang.String |
ON_SIZE
The onSize event (used with
SizeEvent ). |
static java.lang.String |
ON_SLIDE
The onSlide event (used with
Event ). |
static java.lang.String |
ON_SORT
The onSort event (used with
Event )
to notify a request for sorting. |
static java.lang.String |
ON_STATE_CHANGE
The onStateChange event used with
StateChangeEvent . |
static java.lang.String |
ON_STUB
The onStub event (used with
StubEvent )
to denote an event sent from the peer widget of a stub component
(at the client). |
static java.lang.String |
ON_SWIPE
The onSwipe event (used with
SwipeEvent ). |
static java.lang.String |
ON_TARGET_CLICK
The onTargetClick event (used with
MouseEvent ). |
static java.lang.String |
ON_TIMER
The onTimer event (used with
Event ). |
static java.lang.String |
ON_UNGROUP
The onUngroup event (used with
Event )
to notify a request for ungrouping. |
static java.lang.String |
ON_UPLOAD
The onUpload event (used with
UploadEvent . |
static java.lang.String |
ON_URI_CHANGE
The onURIChange event (used with
URIEvent )
to notify that the associated URI of a component is changed. |
static java.lang.String |
ON_USER
The onUser event.
|
static java.lang.String |
ON_VISIBILITY_CHANGE
The onVisibilityChange event (used with
VisibilityChangeEvent ). |
static java.lang.String |
ON_Z_INDEX
The onZIndex event (used with
ZIndexEvent ). |
Modifier and Type | Method and Description |
---|---|
static void |
addEventListeners(Component comp,
java.lang.Object controller)
Add onXxx event handler defined in controller object to the specified
component.
|
static void |
echoEvent(Event event)
Echos an event.
|
static void |
echoEvent(java.lang.String name,
Component target,
java.lang.Object data)
Echos an event.
|
static void |
echoEvent(java.lang.String name,
Component target,
java.lang.String data)
Echos an event.
|
static Event |
getRealOrigin(ForwardEvent event)
Returns the real origin event of a forwarded event.
|
static boolean |
inEventListener()
Returns whether the current thread is an event listener.
|
static boolean |
isListened(Component comp,
java.lang.String evtnm,
boolean asap)
Returns whether an event handler or listener is available for
the specified component and event.
|
static boolean |
isValid(java.lang.String name)
Returns whether an event name is valid.
|
static void |
postEvent(Component realTarget,
Event event)
Queues the give event for the specified target to this execution.
|
static void |
postEvent(Event event)
Posts an event to the current execution.
|
static void |
postEvent(int priority,
Component realTarget,
Event event)
Queues the give event for the specified target to this execution.
|
static void |
postEvent(int priority,
Event event)
Posts an event to the current execution with the specified priority.
|
static void |
postEvent(int priority,
java.lang.String name,
Component target,
java.lang.Object data)
Posts an instance of
Event to the current execution
with the specified priority. |
static void |
postEvent(java.lang.String name,
Component target,
java.lang.Object data)
Posts an instance of
Event to the current execution. |
static void |
sendEvent(Component comp,
Event event)
Sends the event to the specified component and process it
immediately.
|
static void |
sendEvent(Event event)
Sends the event to the target specified in the event, and processes it immediately.
|
static void |
sendEvent(java.lang.String name,
Component target,
java.lang.Object data)
Sends the event to the target, and processes it immediately.
|
public static final java.lang.String ON_CLICK
MouseEvent
).public static final java.lang.String ON_RIGHT_CLICK
MouseEvent
).public static final java.lang.String ON_DOUBLE_CLICK
MouseEvent
).public static final java.lang.String ON_MOUSE_OVER
MouseEvent
).
Notice, if Internet connection is too far, the user might already move the mouse out of a widget when the server receives onMouseOver.
public static final java.lang.String ON_MOUSE_OUT
MouseEvent
).public static final java.lang.String ON_TARGET_CLICK
MouseEvent
).public static final java.lang.String ON_OK
KeyEvent
).public static final java.lang.String ON_CANCEL
KeyEvent
).public static final java.lang.String ON_CTRL_KEY
KeyEvent
).public static final java.lang.String ON_CHANGE
InputEvent
).public static final java.lang.String ON_CHANGING
InputEvent
).public static final java.lang.String ON_ERROR
ErrorEvent
).public static final java.lang.String ON_SCROLL
ScrollEvent
).public static final java.lang.String ON_SCROLLING
ScrollEvent
).public static final java.lang.String ON_SWIPE
SwipeEvent
).public static final java.lang.String ON_SELECT
SelectEvent
).public static final java.lang.String ON_SELECTION
SelectionEvent
).public static final java.lang.String ON_CHECK
CheckEvent
).public static final java.lang.String ON_MOVE
MoveEvent
).public static final java.lang.String ON_SIZE
SizeEvent
).public static final java.lang.String ON_AFTER_SIZE
AfterSizeEvent
).public static final java.lang.String ON_Z_INDEX
ZIndexEvent
).public static final java.lang.String ON_OPEN
OpenEvent
).public static final java.lang.String ON_CLOSE
Event
)
used to denote the close button is pressed.public static final java.lang.String ON_RENDER
public static final java.lang.String ON_TIMER
Event
).
Sent when a timer is up.public static final java.lang.String ON_FOCUS
Event
).
Sent when a component gets a focus.public static final java.lang.String ON_BLUR
Event
).
Sent when a component loses a focus.public static final java.lang.String ON_DROP
DropEvent
).
Sent when a component is dragged and drop to another.public static final java.lang.String ON_NOTIFY
Event
).
It is not used by any component, but it is, rather, designed to
let users add customized events.public static final java.lang.String ON_SORT
Event
)
to notify a request for sorting.public static final java.lang.String ON_GROUP
Event
)
to notify a request for grouping.public static final java.lang.String ON_UNGROUP
Event
)
to notify a request for ungrouping.public static final java.lang.String ON_UPLOAD
UploadEvent
.public static final java.lang.String ON_BOOKMARK_CHANGE
BookmarkEvent
)
to notify that user pressed BACK, FORWARD or specified URL directly
that causes the bookmark is changed (but still in the same desktop).
All root components of all pages of the desktop will receive this event.
public static final java.lang.String ON_URI_CHANGE
URIEvent
)
to notify that the associated URI of a component is changed.
Currently only the iframe component supports this event.public static final java.lang.String ON_CLIENT_INFO
ClientInfoEvent
).public static final java.lang.String ON_VISIBILITY_CHANGE
VisibilityChangeEvent
).
Only for browsers that support HTML 5 Page Visibility APIpublic static final java.lang.String ON_CREATE
CreateEvent
) to notify a component
that it (and its children) has been created by ZK's evaluating a ZUML page.public static final java.lang.String ON_MODAL
Event
) to notify a component
shall become modal. Currently, only ZUL's window components support it.
Notice that it is not fired if the event thread is disabled (default).
public static final java.lang.String ON_PIGGYBACK
Event
) used to notify
a root component that the client has sent a request to the server.
It is meaningful only if it is registered to the root component.
Once registered, it is called
each time the client sends a request to the server.
The onPiggyback's event listener is processed after all other
events are processed.
The onPiggyback event is designed to let developers piggyback the least-emergent UI updates to the client.
public static final java.lang.String ON_USER
public static final java.lang.String ON_MINIMIZE
MinimizeEvent
).public static final java.lang.String ON_MAXIMIZE
MaximizeEvent
).public static final java.lang.String ON_FULFILL
FulfillEvent
)
to denote a fulfill condition has been applied.
Developer usually listens to this event to process the
new created children. For example, you might invoke
Components.wireFellows(org.zkoss.zk.ui.IdSpace, java.lang.Object)
to process these new components.public static final java.lang.String ON_STUB
StubEvent
)
to denote an event sent from the peer widget of a stub component
(at the client).public static final java.lang.String ON_DESKTOP_RECYCLE
Event
)
to notify that a desktop has been recycled.
All top-level components will receive this event when
recycled.
Refer to DesktopRecycle
for desktop
recycling.
public static final java.lang.String ON_DEFERRED_EVALUATION
Event
)
to notify a component the Composer.doAfterCompose(Component)
phase is done,
and can evaluate deferred expressions if any.public static final java.lang.String ON_SLIDE
Event
).public static final java.lang.String ON_HISTORY_POP_STATE
HistoryPopStateEvent
).public static final java.lang.String ON_SEARCHING
InputEvent
).public static final java.lang.String ON_STATE_CHANGE
StateChangeEvent
.public static final java.lang.String ON_SCRIPT_ERROR
ScriptErrorEvent
.public static final boolean isValid(java.lang.String name)
The event name must start with on and the third character must be upper case.
public static final boolean inEventListener()
public static boolean isListened(Component comp, java.lang.String evtnm, boolean asap)
A event handler is either a public method named onXxx or
a ZUL attribute named onXxx, where onXxx is the event name.
A event listener is EventListener
being added
by Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)
and Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)
.
Unlike Component.isListenerAvailable(java.lang.String, boolean)
, which checks
only the event listener, this method
check both event handlers and listeners, i.e.,
the onXxx members defined in ZUML, the onXxx method defined
in the implementation class, and the event listener registered.
asap
- whether to check only non-deferrable listener,
i.e., not implementing Deferrable
,
or Deferrable.isDeferrable()
is false.Deferrable
,
Component.isListenerAvailable(java.lang.String, boolean)
public static void sendEvent(Component comp, Event event)
public static void sendEvent(Event event)
Note: Event.getTarget()
cannot be null.
public static void sendEvent(java.lang.String name, Component target, java.lang.Object data)
target
- the target of the event (never null)public static final void postEvent(Event event)
The priority of the event is assumed to be 0. Refer to
postEvent(int, Event)
.
On the other hand, the event sent by sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
is processed
immediately without posting it to the queue.
Note: if the target of an event is not attached to the page yet, the event is ignored silently.
public static final void postEvent(java.lang.String name, Component target, java.lang.Object data)
Event
to the current execution.
The priority of the event is assumed to be 0. Refer to
postEvent(int, String, Component, Object)
.
public static final void postEvent(int priority, Event event)
The posted events are processed from the higher priority to the lower one. If two events are posted with the same priority, the earlier the event being posted is processed earlier (first-in-first-out).
priority
- the priority of the event. The higher the priority is, the earlier it
is handled.postEvent(Event)
is 0.
Applications shall not use the priority higher than 10,000 and
lower than -10,000 since they are reserved for component development.public static final void postEvent(int priority, Component realTarget, Event event)
Event.getTarget()
.priority
- the priority of the event. The default priority is 0
and the higher value means higher priority.realTarget
- the target component that will receive the event.
If null, it means broadcast, i.e., all root components will receive
this event.
public static final void postEvent(Component realTarget, Event event)
Event.getTarget()
.realTarget
- the target component that will receive the event.
If null, it means broadcast, i.e., all root components will receive
this event.
public static final void postEvent(int priority, java.lang.String name, Component target, java.lang.Object data)
Event
to the current execution
with the specified priority.
The posted events are processed from the higher priority to the lower one. If two events are posted with the same priority, the earlier the event being posted is processed earlier (first-in-first-out).
The priority posted by posted by postEvent(Event)
is
0.
Applications shall not use the priority higher than 10,000 and
lower than -10,000 since they are reserved for component
development.
priority
- the priority of the event.public static final void echoEvent(java.lang.String name, Component target, java.lang.String data)
It is usually if you want to prompt the user before doing a long operation. A typical case is to open a highlighted window to prevent the user from clicking any button before the operation gets done.
It is the same as echoEvent(name, target, (Object)data)
.
name
- the event name, such as onSomethingtarget
- the component to receive the event (never null).data
- the extra information, or null if not available.
It will become Event.getData()
.sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
,
echoEvent(String, Component, Object)
public static final void echoEvent(Event event)
It is usually if you want to prompt the user before doing a long operation. A typical case is to open a highlighted window to prevent the user from clicking any button before the operation gets done.
sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
public static final void echoEvent(java.lang.String name, Component target, java.lang.Object data)
It is usually if you want to prompt the user before doing a long operation. A typical case is to open a highlighted window to prevent the user from clicking any button before the operation gets done.
name
- the event name, such as onSomethingtarget
- the component to receive the event (never null).data
- the extra information, or null if not available.
It will become Event.getData()
.sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
public static final void addEventListeners(Component comp, java.lang.Object controller)
Add onXxx event handler defined in controller object to the specified
component.
The controller is a POJO file with onXxx methods(the event handler codes).
This utility method registers these onXxx events to the specified
component so you don't have to implement and add EventListener
into the component one by one.
All public methods whose names start with "on" in controller object are considered as event handlers and the corresponding event is listened. For example, if the controller object has a method named onOK, then the onOK event is listened and the onOK method is called when the event is received.
Since 3.0.8, this method treats ForwardEvent specially. If the
event argument going to be passed into the onXxx event listener is a
ForwardEvent and the onXxx event listener defined in the controller
specifies a specific event class as its parameter rather than generic
Event or ForwardEvent class, then this method will unwrap the
ForwardEvent automatically
(see ForwardEvent.getOrigin()
)
and pass the original forwarded event to the defined onXxx event listener.
This is a useful tool for MVC design practice. You can write onXxx event handler codes in controller object and use this utility to register the events to the specified component.
comp
- the component to be registered the eventscontroller
- a POJO file with onXxx methods(event handlers)GenericEventListener
public static final Event getRealOrigin(ForwardEvent event)
ForwardEvent.getOrigin()
.
Notice that a forward event might be forwarded again, so
ForwardEvent.getOrigin()
might not be the real origin.Copyright © 2005-2023 Potix Corporation. All Rights Reserved.