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,java.io.Serializable,java.lang.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 aPushControllerit enables server push in a Cockpit application. A push component is responsible for handling the execution of itsPushControllerand sendingCockpitEvents 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 ownPushControllerinstance, typically implemented as a Java thread. ThePushController(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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_DELAY
-
Constructor Summary
Constructors Constructor Description PushComponent(java.lang.Class<T> controllerClass)Creates a new push component instance with the default update interval and aPushControllerof the class specified bycontrollerClass.PushComponent(java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(CockpitEvent event)Adds an event to this push components internal event queue.protected voidappendChildInternal(org.zkoss.zk.ui.Component child)voidclearEvents()Clears the event queue i.e.voiddesktopRemoved(org.zkoss.zk.ui.Desktop desktop)voiddetach()voiddispatchEvents()Dispatches the queued events.voidenableServerPush(boolean enable)java.util.List<CockpitEvent>getEvents()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, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, 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, setZIndexDirectly
-
Methods 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, isChildable, 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, willSerialize
-
-
-
-
Field Detail
-
DEFAULT_DELAY
protected static final int DEFAULT_DELAY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PushComponent
public PushComponent(java.lang.Class<T> controllerClass) throws java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.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:
java.lang.IllegalArgumentException- if the push controller could not be createdjava.lang.InstantiationException- if the push controller could not be createdjava.lang.IllegalAccessException- if the push controller could not be created- See Also:
PushComponent(Class, int),PushComponent(PushController),PushComponent(PushController, int)
-
PushComponent
public PushComponent(java.lang.Class<T> controllerClass, int updateInterval) throws java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.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:
java.lang.IllegalArgumentException- if the push controller could not be createdjava.lang.InstantiationException- if the push controller could not be createdjava.lang.IllegalAccessException- if the push controller could not be created- See Also:
PushComponent(Class),PushComponent(PushController),PushComponent(PushController, int)
-
PushComponent
public PushComponent(T controller)
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(PushController, int),PushComponent(Class),PushComponent(Class, int)
-
PushComponent
public PushComponent(T controller, int updateInterval)
Creates a new push component instance with the specifiedPushControllercontrollerand an update interval ofupdateIntervalmilliseconds.- Parameters:
controller- the push controllerupdateInterval- the update interval in milliseconds
-
-
Method Detail
-
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
public void addEvent(CockpitEvent event)
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
public java.util.List<CockpitEvent> 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)
-
-