Class SimpleWebApp
- java.lang.Object
-
- org.zkoss.zk.ui.impl.AbstractWebApp
-
- org.zkoss.zk.ui.http.SimpleWebApp
-
- All Implemented Interfaces:
org.zkoss.util.resource.Locator,Scope,WebAppCtrl,WebApp
public class SimpleWebApp extends AbstractWebApp
A servlet-based Web application.- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description SimpleWebApp()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddScopeListener(ScopeListener listener)Adds a listener to listen whether this scope is changed.java.lang.ObjectgetAttribute(java.lang.String name)Returns the value of the specified custom attribute.java.util.Map<java.lang.String,java.lang.Object>getAttributes()Returns a map of custom attributes associated with this object.java.lang.StringgetDirectory()java.lang.StringgetInitParameter(java.lang.String name)Returns the value of the named context-wide initialization parameter, or null if the parameter does not exist.java.lang.Iterable<java.lang.String>getInitParameterNames()Returns the names of the context's initialization parameters as an iterable String objects (never null).java.lang.StringgetMimeType(java.lang.String file)Returns the MIME type of the specified file, or null if the MIME type is not known.java.lang.StringgetRealPath(java.lang.String path)Returns a String containing the real path for a given virtual path.java.net.URLgetResource(java.lang.String path)Returns a URL to the resource that is mapped to a specified path.java.io.InputStreamgetResourceAsStream(java.lang.String path)Returns the resource located at the named path as an InputStream object.java.util.Set<java.lang.String>getResourcePaths(java.lang.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.java.lang.StringgetResourceURI()Returns the URI for ZK resource.java.lang.StringgetResourceURI(boolean encode)Returns the URI for ZK resource that can be encoded or not.jakarta.servlet.ServletContextgetServletContext()Returns the servlet context of this application.java.lang.StringgetUpdateURI()Returns the URI for asynchronous update.java.lang.StringgetUpdateURI(boolean encode)Returns the URI for asynchronous update that can be encoded or not.WebAppgetWebApp(java.lang.String uripath)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..booleanhasAttribute(java.lang.String name)Returns if a custom attribute is associated with this object (scope).voidinit(java.lang.Object context, Configuration config)Initializes this Web application.voidlog(java.lang.String msg)Writes the specified message to a servlet log file, usually an event log.voidlog(java.lang.String msg, java.lang.Throwable ex)Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.java.lang.ObjectremoveAttribute(java.lang.String name)Removes the specified custom attribute.booleanremoveScopeListener(ScopeListener listener)Removes a change listener from this scope.java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value)Sets the value of the specified custom attribute.-
Methods inherited from class org.zkoss.zk.ui.impl.AbstractWebApp
destroy, getAppName, getAttribute, getAuDecoder, getBuild, getBuildStamp, getConfiguration, getDesktopCache, getDesktopCacheProvider, getFailoverManager, getIdGenerator, getSessionCache, getSubversion, getUiEngine, getUiFactory, getVersion, hasAttribute, loadBuild, removeAttribute, sessionDestroyed, sessionDidActivate, sessionWillPassivate, setAppName, setAttribute, setAuDecoder, setDesktopCacheProvider, setFailoverManager, setIdGenerator, setSessionCache, setUiEngine, setUiFactory
-
-
-
-
Method Detail
-
init
public void init(java.lang.Object context, Configuration config)Description copied from interface:WebAppCtrlInitializes this Web application.- Specified by:
initin interfaceWebAppCtrl- Overrides:
initin classAbstractWebApp- Parameters:
context- the servlet context, if servlets are used. Currently, ZK supports only servlets. In the future there might be more to support.config- the configuration (never null)
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface:WebAppReturns the value of the specified custom attribute.
-
hasAttribute
public boolean hasAttribute(java.lang.String name)
Description copied from interface:ScopeReturns if a custom attribute is associated with this object (scope).Notice that
nullis a valid value, so you can tell if an attribute is associated by examining the return value ofScope.getAttribute(java.lang.String).
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)Description copied from interface:WebAppSets the value of the specified custom attribute.- Returns:
- the previous value if any (since ZK 5)
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface:WebAppRemoves the specified custom attribute.- Returns:
- the previous value if any (since ZK 5)
-
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Description copied from interface:WebAppReturns a map of custom attributes associated with this object.
-
addScopeListener
public boolean addScopeListener(ScopeListener listener)
Description copied from interface:ScopeAdds a listener to listen whether this scope is changed. The listener is called when a custom attribute is added, removed, or the parent is changed.- Returns:
- weather the listener is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.
-
removeScopeListener
public boolean removeScopeListener(ScopeListener listener)
Description copied from interface:ScopeRemoves a change listener from this scope.- Returns:
- false if listener is not added before.
-
getUpdateURI
public java.lang.String getUpdateURI()
Description copied from interface:WebAppReturns the URI for asynchronous update.Both
WebApp.getUpdateURI()andDesktop.getUpdateURI(java.lang.String)are encoded withExecution.encodeURL(java.lang.String)- See Also:
Desktop.getUpdateURI(java.lang.String)
-
getUpdateURI
public java.lang.String getUpdateURI(boolean encode)
Description copied from interface:WebAppReturns 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 asWebApp.getUpdateURI()ifencodeis true.
-
getResourceURI
public java.lang.String getResourceURI()
Description copied from interface:WebAppReturns the URI for ZK resource.Both
WebApp.getResourceURI()andDesktop.getResourceURI(java.lang.String)are encoded withExecution.encodeURL(java.lang.String)- See Also:
Desktop.getResourceURI(java.lang.String)
-
getResourceURI
public java.lang.String getResourceURI(boolean encode)
Description copied from interface:WebAppReturns 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 asWebApp.getResourceURI()ifencodeis true.
-
getWebApp
public WebApp getWebApp(java.lang.String uripath)
Description copied from interface:WebAppReturns 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..
-
getDirectory
public java.lang.String getDirectory()
-
getResource
public java.net.URL getResource(java.lang.String path)
Description copied from interface:WebAppReturns 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.
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String path)
Description copied from interface:WebAppReturns 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.
-
getInitParameter
public java.lang.String getInitParameter(java.lang.String name)
Description copied from interface:WebAppReturns the value of the named context-wide initialization parameter, or null if the parameter does not exist.
-
getInitParameterNames
public java.lang.Iterable<java.lang.String> getInitParameterNames()
Description copied from interface:WebAppReturns the names of the context's initialization parameters as an iterable String objects (never null).
-
getRealPath
public java.lang.String getRealPath(java.lang.String path)
Description copied from interface:WebAppReturns 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
public java.lang.String getMimeType(java.lang.String file)
Description copied from interface:WebAppReturns 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
public java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
Description copied from interface:WebAppReturns 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/"}.
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()
Description copied from interface:WebAppReturns the servlet context of this application.
-
log
public void log(java.lang.String msg)
Description copied from interface:WebAppWrites 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.
-
log
public void log(java.lang.String msg, java.lang.Throwable ex)Description copied from interface:WebAppWrites 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.
-
-