Class PushComponent<T extends PushController>
java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.Span
de.hybris.platform.cockpit.components.PushComponent<T>
- All Implemented Interfaces:
DesktopRemovalAwareComponent,Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
public class PushComponent<T extends PushController>
extends org.zkoss.zul.Span
implements DesktopRemovalAwareComponent
A push component is a component which allows ZK components to be updated asynchronously using reverse Ajax.
Together with a
PushController it enables server push in a Cockpit application. A push component is responsible for
handling the execution of its PushController and sending CockpitEvents in an asynchronous fashion. It does not
allow any child components to be added and should not be used for visually displaying content.
Each push component typically has (or creates) its own PushController instance, typically implemented as a Java thread.
The PushController (thread) is started as soon as the push component has been rendered by the browser using ZK's timer
events.
Note: Each thread is gently stopped (within the duration of the specified update interval) once the desktop to which
this push component belongs has been removed. However, in order to avoid excessive creation of threads a push component should
typically be added to a relatively "long-lived" component e.g. the ZK application's root component.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children -
Field Summary
FieldsFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
ConstructorsConstructorDescriptionPushComponent(Class<T> controllerClass) Creates a new push component instance with the default update interval and aPushControllerof the class specified bycontrollerClass.PushComponent(Class<T> controllerClass, int updateInterval) Creates a new push component instance with the specified update interval and aPushControllerof the class specified bycontrollerClass.PushComponent(T controller) Creates a new push component instance with the specifiedPushControllercontrollerwith an update interval set to the value ofcontroller's update interval.PushComponent(T controller, int updateInterval) Creates a new push component instance with the specifiedPushControllercontrollerand an update interval ofupdateIntervalmilliseconds. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvent(CockpitEvent event) Adds an event to this push components internal event queue.protected voidappendChildInternal(org.zkoss.zk.ui.Component child) voidClears the event queue i.e.voiddesktopRemoved(org.zkoss.zk.ui.Desktop desktop) voiddetach()voidDispatches the queued events.voidenableServerPush(boolean enable) Returns the events in the internal event queue.booleaninsertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild) voidsetParent(org.zkoss.zk.ui.Component parent) Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, renderProperties, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, service, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, invalidate, invalidatePartial, isChildable, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerializeMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
invalidatePartial
-
Field Details
-
DEFAULT_DELAY
protected static final int DEFAULT_DELAY- See Also:
-
-
Constructor Details
-
PushComponent
public PushComponent(Class<T> controllerClass) throws IllegalArgumentException, InstantiationException, IllegalAccessException Creates a new push component instance with the default update interval and aPushControllerof the class specified bycontrollerClass.- Parameters:
controllerClass- the class of the push controller to be used- Throws:
IllegalArgumentException- if the push controller could not be createdInstantiationException- if the push controller could not be createdIllegalAccessException- if the push controller could not be created- See Also:
-
PushComponent
public PushComponent(Class<T> controllerClass, int updateInterval) throws IllegalArgumentException, InstantiationException, IllegalAccessException Creates a new push component instance with the specified update interval and aPushControllerof the class specified bycontrollerClass.- Parameters:
controllerClass- the class of the push controller to be usedupdateInterval- the update interval in milliseconds- Throws:
IllegalArgumentException- if the push controller could not be createdInstantiationException- if the push controller could not be createdIllegalAccessException- if the push controller could not be created- See Also:
-
PushComponent
Creates a new push component instance with the specifiedPushControllercontrollerwith an update interval set to the value ofcontroller's update interval.- Parameters:
controller- the push controller- See Also:
-
PushComponent
Creates a new push component instance with the specifiedPushControllercontrollerand an update interval ofupdateIntervalmilliseconds.- Parameters:
controller- the push controllerupdateInterval- the update interval in milliseconds
-
-
Method Details
-
insertBefore
public boolean insertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild) - Specified by:
insertBeforein interfaceorg.zkoss.zk.ui.Component- Overrides:
insertBeforein classorg.zkoss.zk.ui.AbstractComponent
-
appendChildInternal
protected void appendChildInternal(org.zkoss.zk.ui.Component child) -
clearEvents
public void clearEvents()Clears the event queue i.e. removes all the previously queued events. -
addEvent
Adds an event to this push components internal event queue. The events are typically dispatched as soon as control is returned from the push controller thread.- Parameters:
event- the event to be dispatched
-
getEvents
Returns the events in the internal event queue.- Returns:
- the queued events
-
dispatchEvents
public void dispatchEvents()Dispatches the queued events. -
desktopRemoved
public void desktopRemoved(org.zkoss.zk.ui.Desktop desktop) - Specified by:
desktopRemovedin interfaceDesktopRemovalAwareComponent
-
detach
public void detach()- Specified by:
detachin interfaceorg.zkoss.zk.ui.Component- Overrides:
detachin classorg.zkoss.zk.ui.AbstractComponent
-
setParent
public void setParent(org.zkoss.zk.ui.Component parent) - Specified by:
setParentin interfaceorg.zkoss.zk.ui.Component- Overrides:
setParentin classorg.zkoss.zk.ui.AbstractComponent
-
enableServerPush
public void enableServerPush(boolean enable)
-