Class Events
- Author:
- tomyeh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe onAcrossPage event used withEvent.static final StringThe onAfterSize event (used withAfterSizeEvent).static final StringThe onAnchorPos event used withEvent.static final StringThe onBlur event (used withEvent).static final StringThe onBookmarkChange event (used withBookmarkEvent) to notify that user pressed BACK, FORWARD or specified URL directly that causes the bookmark is changed (but still in the same desktop).static final StringThe onCancel event (used withKeyEvent).static final StringThe onChange event (used withInputEvent).static final StringThe onChanging event (used withInputEvent).static final StringThe onCheck event (used withCheckEvent).static final StringThe onCheckSelectAll event used withEvent.static final StringThe onClick event (used withMouseEvent).static final StringThe onClientInfo event (used withClientInfoEvent).static final StringThe onClose event (used withEvent) used to denote the close button is pressed.static final StringThe onCreate event (used withCreateEvent) to notify a component that it (and its children) has been created by ZK's evaluating a ZUML page.static final StringThe onCtrlKey event (used withKeyEvent).static final StringThe onDataLoading event used withEvent.static final StringThe onDeferredEvaluation event (used withEvent) to notify a component theComposer.doAfterCompose(Component)phase is done, and can evaluate deferred expressions if any.static final StringThe onDesktopRecycle event (used withEvent) to notify that a desktop has been recycled.static final StringThe onDoubleClick event (used withMouseEvent).static final StringThe onDrop event (used withDropEvent).static final StringThe onError event (used withErrorEvent).static final StringThe onFocus event (used withEvent).static final StringThe onFulfill event (used withFulfillEvent) to denote a fulfill condition has been applied.static final StringThe onGroup event (used withEvent) to notify a request for grouping.static final StringThe onHistoryPopState event (used withHistoryPopStateEvent).static final StringThe onInnerWidth event used withEvent.static final StringThe onMaximize event (used withMaximizeEvent).static final StringThe onMinimize event (used withMinimizeEvent).static final StringThe onModal event (used withEvent) to notify a component shall become modal.static final StringThe onMouseOut event (used withMouseEvent).static final StringThe onMouseOver event (used withMouseEvent).static final StringThe onMove event (used withMoveEvent).static final StringThe onNotify event (used withEvent).static final StringThe onOK event (used withKeyEvent).static final StringThe onOpen event (used withOpenEvent).static final StringThe onPiggyback event (used withEvent) used to notify a root component that the client has sent a request to the server.static final StringThe onRender request.static final StringThe onRightClick event (used withMouseEvent).static final StringThe onScriptError event used withScriptErrorEvent.static final StringThe onScroll event (used withScrollEvent).static final StringThe onScrollPos event used withEvent.static final StringThe onScrolling event (used withScrollEvent).static final StringThe onSearching event (used withInputEvent).static final StringThe onSearching event (used withInputEvent).static final StringThe onSelect event (used withSelectEvent).static final StringThe onSelection event (used withSelectionEvent).static final StringThe onSize event (used withSizeEvent).static final StringThe onSlide event (used withEvent).static final StringThe onSort event (used withEvent) to notify a request for sorting.static final StringThe onStateChange event used withStateChangeEvent.static final StringThe onStub event (used withStubEvent) to denote an event sent from the peer widget of a stub component (at the client).static final StringThe onSwipe event (used withSwipeEvent).static final StringThe onTargetClick event (used withMouseEvent).static final StringThe onTimeZoneChange event used withEvent.static final StringThe onTimer event (used withEvent).static final StringThe onTopPad event used withEvent.static final StringThe onUngroup event (used withEvent) to notify a request for ungrouping.static final StringThe onUpload event (used withUploadEvent.static final StringThe onURIChange event (used withURIEvent) to notify that the associated URI of a component is changed.static final StringThe onUser event.static final StringThe onVisibilityChange event (used withVisibilityChangeEvent).static final StringThe onWeekClick event used withEvent.static final StringThe onZIndex event (used withZIndexEvent). -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidaddEventListeners(Component comp, Object controller) Add onXxx event handler defined in controller object to the specified component.static final voidEchos an event.static final voidEchos an event.static final voidEchos an event.static final EventgetRealOrigin(ForwardEvent event) Returns the real origin event of a forwarded event.static final booleanReturns whether the current thread is an event listener.static booleanisListened(Component comp, String evtnm, boolean asap) Returns whether an event handler or listener is available for the specified component and event.static final booleanReturns whether an event name is valid.static final voidPosts an instance ofEventto the current execution with the specified priority.static final voidQueues the give event for the specified target to this execution.static final voidPosts an event to the current execution with the specified priority.static final voidPosts an instance ofEventto the current execution.static final voidQueues the give event for the specified target to this execution.static final voidPosts an event to the current execution.static voidSends the event to the target, and processes it immediately.static voidSends the event to the specified component and process it immediately.static voidSends the event to the target specified in the event, and processes it immediately.
-
Field Details
-
ON_CLICK
The onClick event (used withMouseEvent).- See Also:
-
ON_RIGHT_CLICK
The onRightClick event (used withMouseEvent).- See Also:
-
ON_DOUBLE_CLICK
The onDoubleClick event (used withMouseEvent).- See Also:
-
ON_MOUSE_OVER
The onMouseOver event (used withMouseEvent).Notice, if Internet connection is too far, the user might already move the mouse out of a widget when the server receives onMouseOver.
- Since:
- 5.0.3
- See Also:
-
ON_MOUSE_OUT
The onMouseOut event (used withMouseEvent).- Since:
- 5.0.3
- See Also:
-
ON_TARGET_CLICK
The onTargetClick event (used withMouseEvent).- Since:
- 9.0.0
- See Also:
-
ON_OK
The onOK event (used withKeyEvent).- See Also:
-
ON_CANCEL
The onCancel event (used withKeyEvent).- See Also:
-
ON_CTRL_KEY
The onCtrlKey event (used withKeyEvent).- See Also:
-
ON_CHANGE
The onChange event (used withInputEvent).- See Also:
-
ON_CHANGING
The onChanging event (used withInputEvent).- See Also:
-
ON_ERROR
The onError event (used withErrorEvent).- See Also:
-
ON_SCROLL
The onScroll event (used withScrollEvent).- See Also:
-
ON_SCROLLING
The onScrolling event (used withScrollEvent).- See Also:
-
ON_SWIPE
The onSwipe event (used withSwipeEvent).- Since:
- 6.5.0
- See Also:
-
ON_SELECT
The onSelect event (used withSelectEvent).- See Also:
-
ON_SELECTION
The onSelection event (used withSelectionEvent).- See Also:
-
ON_CHECK
The onCheck event (used withCheckEvent).- See Also:
-
ON_MOVE
The onMove event (used withMoveEvent).- See Also:
-
ON_SIZE
The onSize event (used withSizeEvent).- See Also:
-
ON_AFTER_SIZE
The onAfterSize event (used withAfterSizeEvent).- Since:
- 6.5.2
- See Also:
-
ON_Z_INDEX
The onZIndex event (used withZIndexEvent).- See Also:
-
ON_OPEN
The onOpen event (used withOpenEvent).- See Also:
-
ON_CLOSE
The onClose event (used withEvent) used to denote the close button is pressed.- See Also:
-
ON_RENDER
The onRender request. There is no event associated with this AU request.- See Also:
-
ON_TIMER
The onTimer event (used withEvent). Sent when a timer is up.- See Also:
-
ON_FOCUS
The onFocus event (used withEvent). Sent when a component gets a focus.- See Also:
-
ON_BLUR
The onBlur event (used withEvent). Sent when a component loses a focus.- See Also:
-
ON_DROP
The onDrop event (used withDropEvent). Sent when a component is dragged and drop to another.- See Also:
-
ON_NOTIFY
The onNotify event (used withEvent). It is not used by any component, but it is, rather, designed to let users add customized events.- See Also:
-
ON_SORT
The onSort event (used withEvent) to notify a request for sorting.- See Also:
-
ON_GROUP
The onGroup event (used withEvent) to notify a request for grouping.- Since:
- 5.0.0
- See Also:
-
ON_UNGROUP
The onUngroup event (used withEvent) to notify a request for ungrouping.- Since:
- 6.5.0
- See Also:
-
ON_UPLOAD
The onUpload event (used withUploadEvent.- See Also:
-
ON_BOOKMARK_CHANGE
The onBookmarkChange event (used withBookmarkEvent) 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.
- Since:
- 3.0.8
- See Also:
-
ON_URI_CHANGE
The onURIChange event (used withURIEvent) to notify that the associated URI of a component is changed. Currently only the iframe component supports this event.- Since:
- 3.5.0
- See Also:
-
ON_CLIENT_INFO
The onClientInfo event (used withClientInfoEvent).- See Also:
-
ON_VISIBILITY_CHANGE
The onVisibilityChange event (used withVisibilityChangeEvent). Only for browsers that support HTML 5 Page Visibility API- Since:
- 6.5.1
- See Also:
-
ON_CREATE
The onCreate event (used withCreateEvent) to notify a component that it (and its children) has been created by ZK's evaluating a ZUML page.- See Also:
-
ON_MODAL
The onModal event (used withEvent) 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).
- See Also:
-
ON_PIGGYBACK
The onPiggyback event (used withEvent) 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.
- Since:
- 2.4.0
- See Also:
-
ON_USER
The onUser event. It is a generic event that an application developer might send from the client. ZK doesn't use this event.- See Also:
-
ON_MINIMIZE
The onMinimize event (used withMinimizeEvent).- Since:
- 3.5.0
- See Also:
-
ON_MAXIMIZE
The onMaximize event (used withMaximizeEvent).- Since:
- 3.5.0
- See Also:
-
ON_FULFILL
The onFulfill event (used withFulfillEvent) to denote a fulfill condition has been applied. Developer usually listens to this event to process the new created children. For example, you might invokeConventionWires.wireFellows(org.zkoss.zk.ui.IdSpace, java.lang.Object)to process these new components.- Since:
- 3.0.8
- See Also:
-
ON_STUB
The onStub event (used withStubEvent) to denote an event sent from the peer widget of a stub component (at the client).- Since:
- 6.0.0
- See Also:
-
ON_DESKTOP_RECYCLE
The onDesktopRecycle event (used withEvent) to notify that a desktop has been recycled. All top-level components will receive this event when recycled.Refer to
DesktopRecyclefor desktop recycling.- Since:
- 5.0.2
- See Also:
-
ON_DEFERRED_EVALUATION
The onDeferredEvaluation event (used withEvent) to notify a component theComposer.doAfterCompose(Component)phase is done, and can evaluate deferred expressions if any.- Since:
- 8.0.0
- See Also:
-
ON_SLIDE
The onSlide event (used withEvent).- Since:
- 8.0.2
- See Also:
-
ON_HISTORY_POP_STATE
The onHistoryPopState event (used withHistoryPopStateEvent).- Since:
- 8.5.0
- See Also:
-
ON_SEARCHING
The onSearching event (used withInputEvent).- Since:
- 9.0.0
- See Also:
-
ON_SEARCH
The onSearching event (used withInputEvent).- Since:
- 10.0.0
- See Also:
-
ON_STATE_CHANGE
The onStateChange event used withStateChangeEvent.- Since:
- 9.6.0
- See Also:
-
ON_SCRIPT_ERROR
The onScriptError event used withScriptErrorEvent.- Since:
- 9.6.0
- See Also:
-
ON_INNER_WIDTH
The onInnerWidth event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_SCROLL_POS
The onScrollPos event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_TOP_PAD
The onTopPad event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_DATA_LOADING
The onDataLoading event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_WEEK_CLICK
The onWeekClick event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_TIME_ZONE_CHANGE
The onTimeZoneChange event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_ANCHOR_POS
The onAnchorPos event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_ACROSS_PAGE
The onAcrossPage event used withEvent.- Since:
- 10.0.0
- See Also:
-
ON_CHECK_SELECT_ALL
The onCheckSelectAll event used withEvent.- Since:
- 10.0.0
- See Also:
-
-
Method Details
-
isValid
Returns whether an event name is valid.The event name must start with on and the third character must be upper case.
-
inEventListener
public static final boolean inEventListener()Returns whether the current thread is an event listener. -
isListened
Returns whether an event handler or listener is available for the specified component and event.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
EventListenerbeing added byComponent.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)andPage.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.- Parameters:
asap- whether to check only non-deferrable listener, i.e., not implementingDeferrable, orDeferrable.isDeferrable()is false.- See Also:
-
sendEvent
Sends the event to the specified component and process it immediately. This method can only be called when processing an event. It is OK to send event to component from another page as long as they are in the same desktop. -
sendEvent
Sends the event to the target specified in the event, and processes it immediately.Note:
Event.getTarget()cannot be null. -
sendEvent
Sends the event to the target, and processes it immediately.- Parameters:
target- the target of the event (never null)- Since:
- 5.0.4
-
postEvent
Posts an event to the current execution.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.
-
postEvent
Posts an instance ofEventto the current execution.The priority of the event is assumed to be 0. Refer to
postEvent(int, String, Component, Object). -
postEvent
Posts an 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).
- Parameters:
priority- the priority of the event. The higher the priority is, the earlier it is handled.
The priority posted bypostEvent(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.- Since:
- 3.0.7
-
postEvent
Queues the give event for the specified target to this execution. The target could be different fromEvent.getTarget().- Parameters:
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.
Notice that postEvent(n, event) is the same as postEvent(n, event.getTarget(), event), but different from postEvent(n, 0, event).- Since:
- 5.0.7
-
postEvent
Queues the give event for the specified target to this execution. The target could be different fromEvent.getTarget().- Parameters:
realTarget- the target component that will receive the event. If null, it means broadcast, i.e., all root components will receive this event.
Notice that postEvent(n, event) is the same as postEvent(n, event.getTarget(), event), but different from postEvent(n, 0, event).- Since:
- 5.0.7
-
postEvent
Posts an instance ofEventto 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.- Parameters:
priority- the priority of the event.- Since:
- 3.0.7
-
echoEvent
Echos an event. By echo we mean the event is fired after the client receives the AU responses and then echoes back. In other words, the event won't be processed in the current execution. Rather, it executes after the client receives the AU responses and then echoes back the event back.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.
Since 10.0.0, ZK EE opened InaccessableWidgetBlockService by default, so it will block echo event for disabled and invisible component, to disable it, set library property `org.zkoss.zkmax.au.IWBS.disable` to `true`.
It is the same as
echoEvent(name, target, (Object)data).- Parameters:
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 becomeEvent.getData().- Since:
- 3.0.2
- See Also:
-
echoEvent
Echos an event. By echo we mean the event is fired after the client receives the AU responses and then echoes back. In other words, the event won't be processed in the current execution. Rather, it executes after the client receives the AU responses and then echoes back the event back.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.
Since 10.0.0, ZK EE opened InaccessableWidgetBlockService by default, so it will block echo event for disabled and invisible component, to disable it, set library property `org.zkoss.zkmax.au.IWBS.disable` to `true`.
- Since:
- 5.0.4
- See Also:
-
echoEvent
Echos an event. By echo we mean the event is fired after the client receives the AU responses and then echoes back. In other words, the event won't be processed in the current execution. Rather, it executes after the client receives the AU responses and then echoes back the event back.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.
Since 10.0.0, ZK EE opened InaccessableWidgetBlockService by default, so it will block echo event for disabled and invisible component, to disable it, set library property `org.zkoss.zkmax.au.IWBS.disable` to `true`.
- Parameters:
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 becomeEvent.getData().- Since:
- 5.0.4
- See Also:
-
addEventListeners
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
EventListenerinto 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.
- Parameters:
comp- the component to be registered the eventscontroller- a POJO file with onXxx methods(event handlers)- Since:
- 3.0.6
- See Also:
-
getRealOrigin
Returns the real origin event of a forwarded event. By real we mean the last non-forward event in the chain ofForwardEvent.getOrigin(). Notice that a forward event might be forwarded again, soForwardEvent.getOrigin()might not be the real origin.- Since:
- 3.5.1
-