Interface WebApp
- All Superinterfaces:
org.zkoss.util.resource.Locator,Scope
- All Known Implementing Classes:
AbstractWebApp,SimpleWebApp
In HTTP, Web application represents a servlet context that supports ZK.
In other word, a Web application is created if
DHtmlLayoutServlet is declared in web.xml.
To get the current Web application, use Desktop.getWebApp().
- Author:
- tomyeh
-
Method Summary
Modifier and TypeMethodDescriptionReturns the application name, never null.getAttribute(String name) Returns the value of the specified custom attribute.Returns a map of custom attributes associated with this object.getBuild()Returns the build identifier, such as 2007121316.Returns the configuration.getInitParameter(String name) Returns the value of the named context-wide initialization parameter, or null if the parameter does not exist.Returns the names of the context's initialization parameters as an iterable String objects (never null).getMimeType(String file) Returns the MIME type of the specified file, or null if the MIME type is not known.getRealPath(String path) Returns a String containing the real path for a given virtual path.getResource(String path) Returns a URL to the resource that is mapped to a specified path.getResourceAsStream(String path) Returns the resource located at the named path as an InputStream object.getResourcePaths(String path) Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.default StringReturns the URI for ZK resource.default StringgetResourceURI(boolean encode) Returns the URI for ZK resource that can be encoded or not.jakarta.servlet.ServletContextReturns the servlet context of this application.intgetSubversion(int portion) Returns a portion of the version in an integer by specifying its index.Returns the URI for asynchronous update.getUpdateURI(boolean encode) Returns the URI for asynchronous update that can be encoded or not.Returns the ZK version, such as "1.1.0" and "2.0.0".Returns the WebApp that corresponds to a specified URL on the server, or null if either none exists or the container wishes to restrict this access..voidWrites the specified message to a servlet log file, usually an event log.voidWrites an explanatory message and a stack trace for a given Throwable exception to the servlet log file.removeAttribute(String name) Removes the specified custom attribute.voidsetAppName(String name) Sets the application name.setAttribute(String name, Object value) Sets the value of the specified custom attribute.Methods inherited from interface org.zkoss.util.resource.Locator
getDirectoryMethods inherited from interface org.zkoss.zk.ui.ext.Scope
addScopeListener, getAttribute, hasAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
-
Method Details
-
getAppName
String getAppName()Returns the application name, never null. Developer can set it to any name that describes his application.Default: ZK
-
setAppName
Sets the application name. Developer can set it to any name that describes his application. -
getVersion
String getVersion()Returns the ZK version, such as "1.1.0" and "2.0.0".- See Also:
-
getSubversion(int)Utils.parseVersion(java.lang.String)Utils.compareVersion(int[], int[])
-
getBuild
String getBuild()Returns the build identifier, such as 2007121316.Each time ZK is built, a different build identifier is assigned.
- Since:
- 3.0.1
-
getSubversion
int getSubversion(int portion) Returns a portion of the version in an integer by specifying its index. For example, getSubversion(0) returns the so-called major version (2 in "2.4.0"), getSubversion(1) returns the so-called minor version (4 in "2.4.0"), and both getSubversion(2) and getSubversion(3) return 0.- Parameters:
portion- which portion of the version; starting from 0. If you want to retrieve the major version, specify 0.- Since:
- 3.0.0
- See Also:
-
getAttribute
Returns the value of the specified custom attribute.- Specified by:
getAttributein interfaceScope
-
setAttribute
Sets the value of the specified custom attribute.- Specified by:
setAttributein interfaceScope- Returns:
- the previous value if any (since ZK 5)
-
removeAttribute
Removes the specified custom attribute.- Specified by:
removeAttributein interfaceScope- Returns:
- the previous value if any (since ZK 5)
-
getAttributes
Returns a map of custom attributes associated with this object.- Specified by:
getAttributesin interfaceScope
-
getWebApp
Returns the WebApp that corresponds to a specified URL on the server, or null if either none exists or the container wishes to restrict this access.. -
getResource
Returns a URL to the resource that is mapped to a specified path.Notice that, since 3.6.3, this method can retrieve the resource starting with "~./". If the path contains the wildcard ('*'), you can use
Execution.locate(java.lang.String)to convert it to a proper string first.- Specified by:
getResourcein interfaceorg.zkoss.util.resource.Locator
-
getResourceAsStream
Returns the resource located at the named path as an InputStream object.Notice that, since 3.6.3, this method can retrieve the resource starting with "~./". If the path contains the wildcard ('*'), you can use
Execution.locate(java.lang.String)to convert it to a proper string first.- Specified by:
getResourceAsStreamin interfaceorg.zkoss.util.resource.Locator
-
getRealPath
Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for "http://host/contextPath/index.html", where contextPath is the context path of thisWebApp.Notice that ZK don't count on this method to retrieve resources. If you want to change the mapping of URI to different resources, override
UiFactory.getPageDefinition(org.zkoss.zk.ui.sys.RequestInfo, java.lang.String)instead. -
getMimeType
Returns the MIME type of the specified file, or null if the MIME type is not known. The MIME type is determined by the configuration of the Web container.Common MIME types are "text/html" and "image/gif".
-
getResourcePaths
Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all relative to the root of the web application and have a leading '/'. For example, for a web application containing/welcome.html /catalog/index.html /catalog/products.html /catalog/offers/books.html /catalog/offers/music.html /customer/login.jsp /WEB-INF/web.xml /WEB-INF/classes/com.acme.OrderServlet.class, getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"} getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}. -
getInitParameter
Returns the value of the named context-wide initialization parameter, or null if the parameter does not exist. -
getInitParameterNames
Returns the names of the context's initialization parameters as an iterable String objects (never null).- Since:
- 6.0.0
-
getUpdateURI
String getUpdateURI()Returns the URI for asynchronous update.Both
getUpdateURI()andDesktop.getUpdateURI(java.lang.String)are encoded withExecution.encodeURL(java.lang.String)- Throws:
NullPointerException- if the current execution is not available- Since:
- 3.6.2
- See Also:
-
getUpdateURI
Returns the URI for asynchronous update that can be encoded or not.- Parameters:
encode- whether to encode withExecution.encodeURL(java.lang.String). It is the same asgetUpdateURI()ifencodeis true.- Throws:
NullPointerException- if the current execution is not available and encode is true.- Since:
- 5.0.0
-
getConfiguration
Configuration getConfiguration()Returns the configuration. -
getServletContext
jakarta.servlet.ServletContext getServletContext()Returns the servlet context of this application.- Since:
- 6.0.0
-
log
Writes the specified message to a servlet log file, usually an event log. The name and type of the servlet log file is specific to the servlet container.- Since:
- 6.0.0
-
log
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file. The name and type of the servlet log file is specific to the servlet container, usually an event log.- Since:
- 6.0.0
-
getResourceURI
Returns the URI for ZK resource.Both
getResourceURI()andDesktop.getResourceURI(java.lang.String)are encoded withExecution.encodeURL(java.lang.String)- Throws:
NullPointerException- if the current execution is not available- Since:
- 9.5.0
- See Also:
-
getResourceURI
Returns the URI for ZK resource that can be encoded or not.- Parameters:
encode- whether to encode withExecution.encodeURL(java.lang.String). It is the same asgetResourceURI()ifencodeis true.- Throws:
NullPointerException- if the current execution is not available and encode is true.- Since:
- 9.5.0
-