|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.ui.impl.DesktopImpl
public class DesktopImpl
The implementation of Desktop.
Note: though DesktopImpl is serializable, it is designed
to work with Web container to enable the serialization of sessions.
It is not suggested to serialize and desrialize it directly since
many fields might be lost.
On the other hand, it is OK to serialize and deserialize
Component.
| Constructor Summary | |
|---|---|
DesktopImpl(WebApp wapp,
java.lang.String updateURI,
java.lang.String path,
java.lang.String deviceType,
java.lang.Object request)
|
|
| Method Summary | ||
|---|---|---|
boolean |
activateServerPush(long timeout)
Activates the current thread for accessing this desktop by the server push. |
|
void |
addComponent(Component comp)
Adds a component to this page. |
|
void |
addListener(java.lang.Object listener)
Adds a listener. |
|
void |
addPage(Page page)
Adds a page to this desktop. |
|
boolean |
addScopeListener(ScopeListener listener)
Adds a listener to listen whether this scope is changed. |
|
void |
afterComponentAttached(Component comp,
Page page)
Invokes UiLifeCycle.afterComponentAttached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page). |
|
void |
afterComponentDetached(Component comp,
Page prevpage)
Invokes UiLifeCycle.afterComponentDetached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page). |
|
void |
afterComponentMoved(Component parent,
Component child,
Component prevparent)
Invokes UiLifeCycle.afterComponentMoved(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component). |
|
void |
afterProcessEvent(Event event)
Invokes EventInterceptor.afterProcessEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object). |
|
Event |
beforePostEvent(Event event)
Invokes EventInterceptor.beforePostEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object). |
|
Event |
beforeProcessEvent(Event event)
Invokes EventInterceptor.beforeProcessEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object). |
|
Event |
beforeSendEvent(Event event)
Invokes EventInterceptor.beforeSendEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object). |
|
boolean |
ceaseSuspendedThread(EventProcessingThread evtthd,
java.lang.String cause)
Ceases the specified event thread. |
|
void |
deactivateServerPush()
Deactivates the thread that has invoked DesktopCtrl.activateServerPush(long)
successfully. |
|
void |
destroy()
Called when the desktop is about to be destroyed. |
|
boolean |
enableServerPush(boolean enable)
Enables or disables the server-push feature. |
|
boolean |
enableServerPush(ServerPush serverpush)
Enables the server-push feature with the specified server-push controller. |
|
java.lang.Object |
getActivationLock()
Returns the lock used to activate an execution. |
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the specified custom attribute associated with the desktop. |
|
java.lang.Object |
getAttribute(java.lang.String name,
boolean recurse)
Returns the custom attribute associated with this object. |
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Returns all custom attributes associated with this desktop. |
|
java.lang.String |
getBookmark()
Returns the current bookmark (never null). |
|
Component |
getComponentByUuid(java.lang.String uuid)
Returns the component of the specified UUID ( Component.getUuid()). |
|
Component |
getComponentByUuidIfAny(java.lang.String uuid)
Returns the component of the specified UUID ( Component.getUuid()), or null if not found. |
|
java.util.Collection<Component> |
getComponents()
Returns all components contained in this desktop. |
|
java.lang.String |
getCurrentDirectory()
Returns the current directory (never null). |
|
Device |
getDevice()
Returns the device that is associated with this desktop. |
|
java.lang.String |
getDeviceType()
Returns the device type that this desktop belongs to. |
|
Media |
getDownloadMedia(java.lang.String medId,
boolean reserved)
Returns the media that is associated with Desktop.getDownloadMediaURI(org.zkoss.util.media.Media, java.lang.String), or
null if not found. |
|
java.lang.String |
getDownloadMediaURI(Media media,
java.lang.String pathInfo)
Returns URI for a media that is used to download to the client. |
|
java.lang.String |
getDynamicMediaURI(Component comp,
java.lang.String pathInfo)
Returns URI for a dynamic generated media associated with a component. |
|
Execution |
getExecution()
Returns the execution, or null if this desktop is not under seving any execution (aka., not locked). |
|
Page |
getFirstPage()
Returns the first page, or null if no page at all (happens when the desktop has been destroyed) |
|
java.lang.String |
getId()
Returns ID of this desktop. |
|
java.lang.Object |
getLastResponse(java.lang.String reqId)
Returns the response for the last request, or null if no response yet, or the specified request ID doesn't match the last one (passed to DesktopCtrl.responseSent(java.lang.String, java.lang.Object)). |
|
int |
getNextKey()
Returns the next available key which is unique in the whole desktop. |
|
java.lang.String |
getNextUuid(Component comp)
Returns the next available UUID for a component. |
|
java.lang.String |
getNextUuid(Page page)
Returns the next available UUID for a page. |
|
Page |
getPage(java.lang.String pageId)
Returns the page of the specified ID or UUID. |
|
Page |
getPageIfAny(java.lang.String pageId)
Returns the page of the specified ID or UUID, or null if no such page. |
|
java.util.Collection<Page> |
getPages()
Returns a readonly collection of all Page in this desktop. |
|
java.lang.String |
getQueryString()
Returns the query string that is contained in the request URL after the path ( Desktop.getRequestPath()), or null if the URL does not have a query
string. |
|
java.lang.String |
getRequestPath()
Returns the path of the request that causes this desktop to be created, or "" if not available. |
|
RequestQueue |
getRequestQueue()
Returns the request queue. |
|
int |
getResponseId(boolean advance)
Returns the sequence ID of the response. |
|
ServerPush |
getServerPush()
Returns the server-push controller, or null if it is not enabled yet. |
|
Session |
getSession()
Returns the session of this desktop. |
|
java.util.Collection<EventProcessingThread> |
getSuspendedThreads()
Returns a collection of suspended event processing threads, or empty if no suspended thread at all. |
|
java.lang.String |
getUpdateURI(java.lang.String pathInfo)
Returns the URI for asynchronous update. |
|
Visualizer |
getVisualizer()
Returns the visualizer associated with this desktop. |
|
WebApp |
getWebApp()
Returns the Web application this desktop belongs to. |
|
boolean |
hasAttribute(java.lang.String name)
Returns if a custom attribute is associated with this object (scope). |
|
boolean |
hasAttribute(java.lang.String name,
boolean recurse)
Returns if a custom attribute is associated with this object. |
|
boolean |
hasPage(java.lang.String pageId)
Returns whether a page exists. |
|
void |
invalidate()
Invalidates the desktop. |
|
void |
invokeDesktopCleanups()
Invokes DesktopCleanup.cleanup(org.zkoss.zk.ui.Desktop) for each relevant
listener registered by Desktop.addListener(java.lang.Object). |
|
void |
invokeExecutionCleanups(Execution exec,
Execution parent,
java.util.List<java.lang.Throwable> errs)
Invokes ExecutionCleanup.cleanup(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution, java.util.List for each relevant
listener registered by Desktop.addListener(java.lang.Object). |
|
void |
invokeExecutionInits(Execution exec,
Execution parent)
Invokes ExecutionInit.init(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution) for each relevant
listener registered by Desktop.addListener(java.lang.Object). |
|
boolean |
isAlive()
Returns whether the desktop is still alive. |
|
boolean |
isServerPushEnabled()
Returns whether the server-push feature is enabled for this desktop. |
|
Component |
mapComponent(java.lang.String uuid,
Component comp)
Maps a component associated with the given UUID to this page. |
|
protected RequestQueue |
newRequestQueue()
Creates the request queue. |
|
void |
onPiggyback()
Called each time when ZK Update Engine retrieves events. |
|
void |
onPiggybackListened(Component comp,
boolean listen)
Called when a component added or removed a listener for Events.ON_PIGGYBACK. |
|
java.util.List<AuResponse> |
piggyResponse(java.util.Collection<AuResponse> response,
boolean reset)
Adds the responses to the so-called piggy-back queue. |
|
void |
recoverDidFail(java.lang.Throwable ex)
Called when the recoving failed. |
|
void |
recycle()
Called when the desktop has been recycled. |
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the specified custom attribute associated with the desktop. |
|
java.lang.Object |
removeAttribute(java.lang.String name,
boolean recurse)
Removes the custom attribute associated with this scope. |
|
boolean |
removeComponent(Component comp,
boolean recycleAllowed)
Removes a component to this page. |
|
boolean |
removeListener(java.lang.Object listener)
Removes a listener. |
|
void |
removePage(Page page)
Removes a page from this desktop. |
|
boolean |
removeScopeListener(ScopeListener listener)
Removes a change listener from this scope. |
|
void |
responseSent(java.lang.String reqId,
java.lang.Object response)
Called when ZK Update Engine has sent a response to the client. |
|
boolean |
scheduledServerPush()
Returns if there is any scheduled task for server push. |
|
|
scheduleServerPush(EventListener<T> listener,
T event)
Schedules a task to run under the server push of the given desktop asynchronously. |
|
void |
service(AuRequest request,
boolean everError)
Processes an AU request. |
|
void |
sessionDidActivate(Session sess)
Notification that the session, which owns this desktop, has just been activated (aka., deserialized) by the Web container. |
|
void |
sessionWillPassivate(Session sess)
Notification that the session, which owns this desktop, is about to be passivated (aka., serialized) by the Web container. |
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of the specified custom attribute associated with the desktop. |
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value,
boolean recurse)
Sets the custom attribute associated with this scope, or the parent scope. |
|
void |
setBookmark(java.lang.String name)
Sets a bookmark to this desktop. |
|
void |
setBookmark(java.lang.String name,
boolean replace)
Sets the bookmark to this desktop. with more control. |
|
void |
setCurrentDirectory(java.lang.String dir)
Sets the current directory. |
|
void |
setDeviceType(java.lang.String deviceType)
Sets the device type that this desktop belongs to. |
|
void |
setExecution(Execution exec)
Sets the execution (used to represent a lock). |
|
void |
setId(java.lang.String id)
Sets the desktop identifier. |
|
void |
setResponseId(int resId)
Sets the sequence ID of the response. |
|
void |
setVisualizer(Visualizer uv)
Sets the visualizer associated with is desktop. |
|
java.lang.String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DesktopImpl(WebApp wapp,
java.lang.String updateURI,
java.lang.String path,
java.lang.String deviceType,
java.lang.Object request)
updateURI - the URI to access the update engine (no expression allowed).
Note: it is NOT encoded yet.path - the path that causes this desktop to create.
If null or empty is specified, it means not available.deviceType - the device type.
If null or empty is specified, "ajax" is assumed.| Method Detail |
|---|
public java.lang.String getId()
Desktop
getId in interface Desktopprotected RequestQueue newRequestQueue()
You may override it to provide your implementation of
RequestQueue to control how to optimize the AU requests.
Default: creates an instance from RequestQueueImpl;
public java.lang.String getDeviceType()
DesktopA device type identifies the type of a client. For example, "ajax" represents the Web browsers with Ajax support, while "mil" represents clients that supports Mobile Interactive markup Language (on Limited Connected Device, such as mobile phones).
A desktop can use the languages belonging to the same device type.
See also LanguageDefinition.getDeviceType().
A component can be added to a desktop only if they belong to the same device type.
Default: depends on the extension of the resource path,
"ajax" if the path or extension not available.
If Richlet is used, its language definition's device type is
assumed.
getDeviceType in interface Desktoppublic Device getDevice()
DesktopNote: the device is shared by all desktops of the same device type.
getDevice in interface Desktoppublic void setDeviceType(java.lang.String deviceType)
DesktopNote: you can change the device type only before any component is attached to a page of the desktop. In other words, you can set the device type only at the initialization stage.
If the device type is changed, any device allocated for this desktop
(Desktop.getDevice()) will be dropped and recreated at the next
invocation to Desktop.getDevice().
setDeviceType in interface Desktoppublic Execution getExecution()
Desktop
getExecution in interface Desktoppublic final Session getSession()
Desktop
getSession in interface Desktoppublic java.lang.String getUpdateURI(java.lang.String pathInfo)
DesktopYou rarely need this method unless for implementing special components, such as file upload.
getUpdateURI in interface DesktoppathInfo - the path to append to the returned URI, or null
to ignore
public java.lang.String getDynamicMediaURI(Component comp,
java.lang.String pathInfo)
DesktopDynamicMedia.getMedia(java.lang.String) to response.
Note: to use with this method, DynamicMedia
must be implemented as part of the object returned by
ComponentCtrl.getExtraCtrl().
Used mainly for component implementation.
getDynamicMediaURI in interface Desktop
public java.lang.String getDownloadMediaURI(Media media,
java.lang.String pathInfo)
DesktopNote: once called, the media belongs to desktop and it is purged automatically. Thus, don't access it again after calling this method.
getDownloadMediaURI in interface Desktop
public Media getDownloadMedia(java.lang.String medId,
boolean reserved)
DesktopCtrlDesktop.getDownloadMediaURI(org.zkoss.util.media.Media, java.lang.String), or
null if not found.
This method is used internally. Developers rarely need to access this method.
getDownloadMedia in interface DesktopCtrlreserved - reserved for future use.
public Page getPage(java.lang.String pageId)
DesktopThis is one of the only few method you could access before activating an execution.
getPage in interface DesktoppageId - the page's ID or UUID. ID has the higher priority.public Page getPageIfAny(java.lang.String pageId)
Desktop
getPageIfAny in interface DesktoppageId - the page's ID or UUID. ID has the higher priority.public boolean hasPage(java.lang.String pageId)
Desktop
hasPage in interface Desktoppublic java.util.Collection<Page> getPages()
DesktopPage in this desktop.
getPages in interface Desktoppublic Page getFirstPage()
Desktop
getFirstPage in interface Desktoppublic java.lang.String getBookmark()
DesktopDesktop.setBookmark(java.lang.String),
because user might use BACK, FORWARD or others to change the bookmark.
getBookmark in interface Desktoppublic void setBookmark(java.lang.String name)
DesktopIt is the same as setBookmark(name, false)
setBookmark in interface Desktop
public void setBookmark(java.lang.String name,
boolean replace)
Desktop
setBookmark in interface Desktopname - the name of the bookmarkreplace - if true, the bookmark is replaced (in the history list)Desktop.setBookmark(String)public java.util.Collection<Component> getComponents()
Desktop
getComponents in interface Desktoppublic Component getComponentByUuid(java.lang.String uuid)
DesktopComponent.getUuid()).
getComponentByUuid in interface Desktoppublic Component getComponentByUuidIfAny(java.lang.String uuid)
DesktopComponent.getUuid()), or null if not found.
getComponentByUuidIfAny in interface Desktoppublic void addComponent(Component comp)
DesktopCtrlIt is used internally and developers shall not invoke it explicityly.
addComponent in interface DesktopCtrl
public boolean removeComponent(Component comp,
boolean recycleAllowed)
DesktopCtrlIt is used internally and developers shall not invoke it explicitly.
removeComponent in interface DesktopCtrlrecycleAllowed - whether it is OK to recycle UUID.
public Component mapComponent(java.lang.String uuid,
Component comp)
DesktopCtrlComponent.getUuid()).
If the given component is null, the mapping of UUID is removed.
Unlike DesktopCtrl.addComponent(org.zkoss.zk.ui.Component) and DesktopCtrl.removeComponent(org.zkoss.zk.ui.Component, boolean), this method simply replaces
the mapping if the given UUID is already mapped to the other component.
It is used internally and developers shall not invoke it explicityly.
mapComponent in interface DesktopCtrlcomp - the component to assoicate with the given UUID.
If not, the association (i.e., mapping) is removed.
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Desktop
getAttributes in interface DesktopgetAttributes in interface Scopepublic java.lang.Object getAttribute(java.lang.String name)
Desktop
getAttribute in interface DesktopgetAttribute in interface Scopepublic boolean hasAttribute(java.lang.String name)
ScopeNotice that null is a valid value, so you can
tell if an attribute is assoicated by examining the return value
of Scope.getAttribute(java.lang.String).
hasAttribute in interface Scope
public java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value)
Desktop
setAttribute in interface DesktopsetAttribute in interface Scopepublic java.lang.Object removeAttribute(java.lang.String name)
Desktop
removeAttribute in interface DesktopremoveAttribute in interface Scope
public java.lang.Object getAttribute(java.lang.String name,
boolean recurse)
Scope
getAttribute in interface Scoperecurse - whether to search its ancestor scope.
If true and the current scope doen't define the attribute,
it searches up its ancestor to see
any of them has defined the specified attribute.
public boolean hasAttribute(java.lang.String name,
boolean recurse)
ScopeNotice that null is a valid value, so you can
tell if an attribute is assoicated by examining the return value
of Scope.getAttribute(java.lang.String).
hasAttribute in interface Scoperecurse - whether to search its ancestor scope.
If true and the current scope doen't define the attribute,
it searches up its ancestor to see
any of them has defined the specified attribute.
public java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value,
boolean recurse)
Scope
setAttribute in interface Scoperecurse - whether to look up the parent scope for the
existence of the attribute.Scope.setAttribute(String,Object).
public java.lang.Object removeAttribute(java.lang.String name,
boolean recurse)
Scope
removeAttribute in interface Scoperecurse - whether to look up the parent scope for the
existence of the attribute.Scope.removeAttribute(String).public boolean addScopeListener(ScopeListener listener)
Scope
addScopeListener in interface Scopepublic boolean removeScopeListener(ScopeListener listener)
Scope
removeScopeListener in interface Scopepublic WebApp getWebApp()
Desktop
getWebApp in interface Desktoppublic java.lang.String getRequestPath()
DesktopPage.getRequestPath()).
For example, "/foo/index.zul" (a ZUML page is requested) or /test (a richlet).
getRequestPath in interface DesktopPage.getRequestPath()public java.lang.String getQueryString()
DesktopDesktop.getRequestPath()), or null if the URL does not have a query
string.
getQueryString in interface Desktoppublic java.lang.String getCurrentDirectory()
Desktop
getCurrentDirectory in interface Desktoppublic void setCurrentDirectory(java.lang.String dir)
Desktop
setCurrentDirectory in interface Desktopdir - the current directory. If null, an empty string is assumed
(means no current directory at all).public RequestQueue getRequestQueue()
DesktopCtrl
getRequestQueue in interface DesktopCtrlpublic void setExecution(Execution exec)
DesktopCtrlUsed only to implement UiEngine.
setExecution in interface DesktopCtrl
public void service(AuRequest request,
boolean everError)
DesktopCtrlTo override the default processing, register an AU request service
AuService by invoking Desktop.addListener(java.lang.Object).
AuService) one-by-one, until
the first one returns true.AuRequest.getComponent() is not null).ComponentCtrl.service(org.zkoss.zk.au.AuRequest, boolean) to handle the service.Event.getEvent(org.zkoss.zk.au.AuRequest)) and then posts the event
(by Events.postEvent(org.zkoss.zk.ui.event.Event)).Notice that the registered AU request service
(AuService) will be called, no matter
the request is targeting a component or a desktop.
And, it can 'intercept' or 'filter' it by returning false.
To send reponses to the client, use
AbstractComponent.smartUpdate(java.lang.String, java.lang.Object),
AbstractComponent.response(org.zkoss.zk.au.AuResponse)
or Component.invalidate().
If you want to intercept events, you can register a listener implementing
EventInterceptor, or overriding DesktopCtrl.afterProcessEvent(org.zkoss.zk.ui.event.Event).
service in interface DesktopCtrleverError - if any error ever occured before
processing this request. In other words, indicates if the previous
request causes any exception.public Visualizer getVisualizer()
DesktopCtrlUsed only to implement UiEngine.
getVisualizer in interface DesktopCtrlpublic void setVisualizer(Visualizer uv)
DesktopCtrlUsed only to implement UiEngine.
setVisualizer in interface DesktopCtrlpublic java.lang.Object getActivationLock()
DesktopCtrlDesktopCtrl.setVisualizer(org.zkoss.zk.ui.sys.Visualizer), this object returned
by this method must be locked first.
Used only to implement UiEngine.
getActivationLock in interface DesktopCtrlpublic int getNextKey()
DesktopCtrl
getNextKey in interface DesktopCtrlpublic java.lang.String getNextUuid(Page page)
DesktopCtrlRawId is used
(developer's responsibility to avoid conflict),
integer overflow (too many UUID in one session, which
can be considered as impossible), or a custom ID generator
(IdGenerator) is used.
getNextUuid in interface DesktopCtrlpublic java.lang.String getNextUuid(Component comp)
DesktopCtrlRawId is used
(developer's responsibility to avoid conflict),
integer overflow (too many UUID in one session, which
can be considered as impossible), or a custom ID generator
(IdGenerator) is used.
getNextUuid in interface DesktopCtrlpublic void addPage(Page page)
DesktopCtrlThis is one of the only few method you could access before activating an execution.
addPage in interface DesktopCtrlpublic void removePage(Page page)
DesktopCtrlNOTE: once a page is removed, you can NOT add it back. You shall just GC it.
removePage in interface DesktopCtrlpublic void setId(java.lang.String id)
DesktopCtrlIt is callable only if it is the recovering phase, i.e.,
ExecutionCtrl.isRecovering() is true.
In other words, callable only in the invocation of
FailoverManager.recover(org.zkoss.zk.ui.Session, org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Desktop).
setId in interface DesktopCtrlpublic void recoverDidFail(java.lang.Throwable ex)
DesktopCtrl
recoverDidFail in interface DesktopCtrlpublic void recycle()
DesktopCtrl
recycle in interface DesktopCtrlpublic boolean isAlive()
Desktop
isAlive in interface DesktopDesktopCtrl.destroy()public void destroy()
DesktopCtrl
destroy in interface DesktopCtrlpublic java.util.Collection<EventProcessingThread> getSuspendedThreads()
DesktopCtrlAn event processing thread is an instance of
EventProcessingThread
Note: if you access this method NOT in an event listener for
the SAME desktop, you have to synchronize the iteration
(though the returned collection is synchronized).
Of course, it is always safe to test whether it is empty
(Collection.isEmpty()).
//Use the following pathern IF it is not in the SAME desktop's listener
Collection c = otherDesktop.getSuspendedThreads();
if (c.isEmpty()) {
//do something accordingly
} else {
synchronized (c) {
for (Iterator it = c.iterator(); it.hasNext();) {
//...
}
}
}
getSuspendedThreads in interface DesktopCtrl
public boolean ceaseSuspendedThread(EventProcessingThread evtthd,
java.lang.String cause)
DesktopCtrl
ceaseSuspendedThread in interface DesktopCtrlcause - an arbitrary text to describe the cause.
It will be the message of the thrown InterruptedException.
public java.lang.String toString()
toString in class java.lang.Objectpublic void sessionWillPassivate(Session sess)
DesktopCtrl
sessionWillPassivate in interface DesktopCtrlpublic void sessionDidActivate(Session sess)
DesktopCtrl
sessionDidActivate in interface DesktopCtrlpublic void addListener(java.lang.Object listener)
DesktopNote: if the listener is added twice, it will be invoked twice when a corresponding event occurs.
addListener in interface Desktoplistener - the listener. It cannot be null.
It must be an instance that implements
DesktopCleanup,
ExecutionInit,
ExecutionCleanup,
UiLifeCycle,
EventInterceptor
and/or AuService.DesktopInit,
EventThreadInit,
EventThreadCleanup,
EventThreadSuspend and
EventThreadResume are not supported.public boolean removeListener(java.lang.Object listener)
Desktop
removeListener in interface DesktopObject.equals(java.lang.Object) is used to check whether a listener is added.public Event beforeSendEvent(Event event)
DesktopCtrlEventInterceptor.beforeSendEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object).
Note: it invokes
Configuration.beforeSendEvent(org.zkoss.zk.ui.event.Event)
automatically.
beforeSendEvent in interface DesktopCtrlpublic Event beforePostEvent(Event event)
DesktopCtrlEventInterceptor.beforePostEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object).
Note: it invokes
Configuration.beforePostEvent(org.zkoss.zk.ui.event.Event)
automatically.
beforePostEvent in interface DesktopCtrl
public Event beforeProcessEvent(Event event)
throws java.lang.Exception
DesktopCtrlEventInterceptor.beforeProcessEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object).
Note: it invokes
Configuration.beforeProcessEvent(org.zkoss.zk.ui.event.Event)
automatically.
beforeProcessEvent in interface DesktopCtrljava.lang.Exception
public void afterProcessEvent(Event event)
throws java.lang.Exception
DesktopCtrlEventInterceptor.afterProcessEvent(org.zkoss.zk.ui.event.Event)
registered by Desktop.addListener(java.lang.Object).
Note: it invokes
Configuration.afterProcessEvent(org.zkoss.zk.ui.event.Event)
automatically.
afterProcessEvent in interface DesktopCtrljava.lang.Exceptionpublic void invokeDesktopCleanups()
DesktopCtrlDesktopCleanup.cleanup(org.zkoss.zk.ui.Desktop) for each relevant
listener registered by Desktop.addListener(java.lang.Object).
Used only internally.
It never throws an exception.
invokeDesktopCleanups in interface DesktopCtrl
public void invokeExecutionInits(Execution exec,
Execution parent)
throws UiException
DesktopCtrlExecutionInit.init(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution) for each relevant
listener registered by Desktop.addListener(java.lang.Object).
Used only internally.
invokeExecutionInits in interface DesktopCtrlexec - the execution that is createdparent - the previous execution, or null if no previous at all
UiException - to prevent an execution from being created
public void invokeExecutionCleanups(Execution exec,
Execution parent,
java.util.List<java.lang.Throwable> errs)
DesktopCtrlExecutionCleanup.cleanup(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution, java.util.List) for each relevant
listener registered by Desktop.addListener(java.lang.Object).
Used only internally.
It never throws an exception but logs and adds it to the errs argument, if not null.
invokeExecutionCleanups in interface DesktopCtrlexec - the execution that is being destroyedparent - the previous execution, or null if no previous at allerrs - a list of exceptions (java.lang.Throwable) if any exception
occured before this method is called, or null if no exeption at all.
Note: you can manipulate the list directly to add or clean up exceptions.
For example, if exceptions are fixed correctly, you can call errs.clear()
such that no error message will be displayed at the client.
public void afterComponentAttached(Component comp,
Page page)
DesktopCtrlUiLifeCycle.afterComponentAttached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page).
afterComponentAttached in interface DesktopCtrl
public void afterComponentDetached(Component comp,
Page prevpage)
DesktopCtrlUiLifeCycle.afterComponentDetached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page).
afterComponentDetached in interface DesktopCtrl
public void afterComponentMoved(Component parent,
Component child,
Component prevparent)
DesktopCtrlUiLifeCycle.afterComponentMoved(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component).
afterComponentMoved in interface DesktopCtrlprevparent - the previous parent. If it is the same as
comp's Component.getParent(), comp is moved in the same parent.public boolean enableServerPush(boolean enable)
DesktopExecutions.activate(org.zkoss.zk.ui.Desktop) for more details.
Default: false
This method uses the default class
(defined by Device.getServerPushClass())
to instantiate the server-push controller.
enableServerPush in interface Desktopenable - whether to enable or to disable the server-push
feature.Executions.activate(org.zkoss.zk.ui.Desktop),
Device.getServerPushClass(),
DesktopCtrl.enableServerPush(org.zkoss.zk.ui.sys.ServerPush)public boolean enableServerPush(ServerPush serverpush)
DesktopCtrlDesktop.enableServerPush(boolean)
instead. This method allows the caller to provide a server push
for more control.
Example:
desktop.enableServerPush(new PollingServerPush(1000,6000,5));
Notice: a server push controller can be used in one desktop. It cannot be shared.
enableServerPush in interface DesktopCtrlserverpush - the server-push controller. If null,
the server-push feature is disabled (for this desktop).
Note: this method will invoke ServerPush.start(org.zkoss.zk.ui.Desktop), so the
caller doesn't need to do it.Desktop.enableServerPush(boolean)public boolean isServerPushEnabled()
DesktopDefault: false.
isServerPushEnabled in interface Desktoppublic ServerPush getServerPush()
DesktopCtrl
getServerPush in interface DesktopCtrl
public <T extends Event> void scheduleServerPush(EventListener<T> listener,
T event)
DesktopCtrlExecutions.schedule(org.zkoss.zk.ui.Desktop, org.zkoss.zk.ui.event.EventListener, T) .
Don't call it directly.
Like DesktopCtrl.activateServerPush(long) and DesktopCtrl.deactivateServerPush(), this method could
be called in any thread, so the implementation of this method has to be safe for concurrent access.
scheduleServerPush in interface DesktopCtrllistener - the task to executeevent - the event to be passed to the task (i.e., the event listener).
It could null or any instance as long as the task recognizes it.public boolean scheduledServerPush()
DesktopCtrl
scheduledServerPush in interface DesktopCtrl
public boolean activateServerPush(long timeout)
throws java.lang.InterruptedException
DesktopCtrlExecutions.activate(org.zkoss.zk.ui.Desktop).
Don't call it directly.
Like DesktopCtrl.scheduleServerPush(org.zkoss.zk.ui.event.EventListener, this method could
be called in any thread, so it has to be safe for concurrent access.
Note: the server push must be enabled first (by use of
Desktop.enableServerPush(boolean)).
activateServerPush in interface DesktopCtrltimeout - the maximum time to wait in milliseconds.
Ingored (i.e., never timeout) if non-positive.
java.lang.InterruptedExceptionpublic void deactivateServerPush()
DesktopCtrlDesktopCtrl.activateServerPush(long)
successfully.
It is called by Executions.deactivate(org.zkoss.zk.ui.Desktop).
Don't call it directly.
deactivateServerPush in interface DesktopCtrl
public void onPiggybackListened(Component comp,
boolean listen)
DesktopCtrlEvents.ON_PIGGYBACK.
The implementation usualy uses it to optimize whether to
call the listener when DesktopCtrl.onPiggyback() is called.
onPiggybackListened in interface DesktopCtrlcomp - the component that adds an listener for
Events.ON_PIGGYBACK.
The component may or may not be a root component.listen - whether the listener is added (or removed).public void onPiggyback()
DesktopCtrlEvents.ON_PIGGYBACK).
The implementation could post events here. It should not process
event here (since event thread might be used).
Used only internally. Application develepers shall not call it.
onPiggyback in interface DesktopCtrl
public void responseSent(java.lang.String reqId,
java.lang.Object response)
DesktopCtrl
responseSent in interface DesktopCtrlreqId - the request ID that the response is generated for.
Ingore if null.response - the response. Ignored if reqId is null.public java.lang.Object getLastResponse(java.lang.String reqId)
DesktopCtrlDesktopCtrl.responseSent(java.lang.String, java.lang.Object)).
The return value is the value passed to resInfo when calling
DesktopCtrl.responseSent(java.lang.String, java.lang.Object).
getLastResponse in interface DesktopCtrlpublic int getResponseId(boolean advance)
DesktopCtrlThe range of the sequence IDs is 1~999.
getResponseId in interface DesktopCtrladvance - whether to advance the number before returning.
If true, the ID is increased and then returned.
If false, the previous value is returnedpublic void setResponseId(int resId)
DesktopCtrlIt is rarely called other than in the recovering mode, i.e.,
ExecutionCtrl.isRecovering() is true.
setResponseId in interface DesktopCtrlresId - a value between 1 and 999.
You can reset the ID by passing a non-positive value.
public java.util.List<AuResponse> piggyResponse(java.util.Collection<AuResponse> response,
boolean reset)
DesktopCtrlThis method is useful for working thread that wants to sent the responses back to the client. A typical example is the Comet-based server push.
piggyResponse in interface DesktopCtrlresponse - the responses to be appended to the piggy-back queue.reset - whether to reset the piggy-back queue after
returning the queued responses.
public void invalidate()
Desktop
invalidate in interface Desktop
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||