public interface Desktop extends Scope
A desktop is created automatically when the first page is created during a request.
To access a Page
, its desktop must be locked first.
Once a desktop is locked to a request, all pages
contained in this desktop are free to access.
Modifier and Type | Method and Description |
---|---|
void |
addListener(java.lang.Object listener)
Adds a listener.
|
boolean |
enableServerPush(boolean enable)
Enables or disables the server-push feature.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the specified custom attribute associated with the desktop.
|
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.
|
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
serving any execution (a.k.a., 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.
|
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 (
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.
|
Session |
getSession()
Returns the session of this desktop.
|
Storage |
getStorage()
Returns the storage in a desktop scope.
|
java.lang.String |
getUpdateURI(java.lang.String pathInfo)
Returns the URI for asynchronous update.
|
WebApp |
getWebApp()
Returns the Web application this desktop belongs to.
|
boolean |
hasPage(java.lang.String pageId)
Returns whether a page exists.
|
void |
invalidate()
Invalidates the desktop.
|
boolean |
isAlive()
Returns whether the desktop is still alive.
|
boolean |
isServerPushEnabled()
Returns whether the server-push feature is enabled for this
desktop.
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the specified custom attribute associated with the desktop.
|
boolean |
removeListener(java.lang.Object listener)
Removes a listener.
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of the specified custom attribute associated with the desktop.
|
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.
|
addScopeListener, getAttribute, hasAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
java.lang.String getDeviceType()
A 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.
void setDeviceType(java.lang.String deviceType)
Note: 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
(getDevice()
) will be dropped and recreated at the next
invocation to getDevice()
.
UiException
- if any component is attached to a page of the desktop.Device getDevice()
Note: the device is shared by all desktops of the same device type.
boolean isAlive()
DesktopCtrl.destroy()
java.lang.String getId()
Execution getExecution()
Session getSession()
WebApp getWebApp()
Page getPage(java.lang.String pageId) throws ComponentNotFoundException
This is one of the only few method you could access before activating an execution.
pageId
- the page's ID or UUID. ID has the higher priority.ComponentNotFoundException
- if page not foundPage getPageIfAny(java.lang.String pageId)
pageId
- the page's ID or UUID. ID has the higher priority.java.util.Collection<Page> getPages()
Page
in this desktop.Page getFirstPage()
boolean hasPage(java.lang.String pageId)
java.util.Map<java.lang.String,java.lang.Object> getAttributes()
getAttributes
in interface Scope
java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface Scope
java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface Scope
java.lang.Object removeAttribute(java.lang.String name)
removeAttribute
in interface Scope
java.util.Collection<Component> getComponents()
Component getComponentByUuid(java.lang.String uuid)
Component.getUuid()
).ComponentNotFoundException
- if component not foundComponent getComponentByUuidIfAny(java.lang.String uuid)
Component.getUuid()
), or null if not found.java.lang.String getUpdateURI(java.lang.String pathInfo)
You rarely need this method unless for implementing special components, such as file upload.
pathInfo
- the path to append to the returned URI, or null
to ignorejava.lang.String getRequestPath()
Page.getRequestPath()
).
For example, "/foo/index.zul" (a ZUML page is requested) or /test (a richlet).
Page.getRequestPath()
java.lang.String getQueryString()
getRequestPath()
), or null if the URL does not have a query
string.java.lang.String getCurrentDirectory()
void setCurrentDirectory(java.lang.String dir)
dir
- the current directory. If null, an empty string is assumed
(means no current directory at all).java.lang.String getBookmark()
setBookmark(java.lang.String)
,
because user might use BACK, FORWARD or others to change the bookmark.void setBookmark(java.lang.String name)
It is the same as setBookmark(name, false)
void setBookmark(java.lang.String name, boolean replace)
name
- the name of the bookmarkreplace
- if true, the bookmark is replaced (in the history list)setBookmark(String)
java.lang.String getDynamicMediaURI(Component comp, java.lang.String pathInfo)
DynamicMedia.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.
java.lang.String getDownloadMediaURI(Media media, java.lang.String pathInfo)
Note: once called, the media belongs to desktop and it is purged automatically. Thus, don't access it again after calling this method.
boolean enableServerPush(boolean enable)
Executions.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.
enable
- 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)
boolean isServerPushEnabled()
Default: false.
void addListener(java.lang.Object listener)
Note: if the listener is added twice, it will be invoked twice when a corresponding event occurs.
listener
- 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.java.lang.IllegalArgumentException
- if not a valid listener.boolean removeListener(java.lang.Object listener)
Object.equals(java.lang.Object)
is used to check whether a listener is added.void invalidate()
Storage getStorage()
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.