org.zkoss.zk.ui.http
Class SimpleWebApp

java.lang.Object
  extended by org.zkoss.zk.ui.impl.AbstractWebApp
      extended by org.zkoss.zk.ui.http.SimpleWebApp
All Implemented Interfaces:
Locator, Scope, WebAppCtrl, WebApp

public class SimpleWebApp
extends AbstractWebApp

A servlet-based Web application.

Author:
tomyeh

Constructor Summary
SimpleWebApp()
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the specified custom attribute.
 java.util.Map getAttributes()
          Returns a map of custom attributes associated with this object.
 java.lang.String getDirectory()
          Returns the directory used to resolve the relative path, or null if relative path is not allowed.
 java.lang.String getInitParameter(java.lang.String name)
          Returns the value of the named context-wide initialization parameter, or null if the parameter does not exist.
 java.util.Iterator getInitParameterNames()
          Returns the names of the context's initialization parameters as an Iterator of String objects, or an empty Iterator if the context has no initialization parameters.
 java.lang.String getMimeType(java.lang.String file)
          Returns the MIME type of the specified file, or null if the MIME type is not known.
 java.lang.Object getNativeContext()
          Returns the native application context, or null if not available.
 java.lang.String getRealPath(java.lang.String path)
          Returns a String containing the real path for a given virtual path.
 java.net.URL getResource(java.lang.String path)
          Returns a URL to the resource that is mapped to a specified path.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Returns the resource located at the named path as an InputStream object.
 java.util.Set 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.
 WebApp getWebApp(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..
 void init(java.lang.Object context, Configuration config)
          Initializes this Web application.
 void removeAttribute(java.lang.String name)
          Removes the specified custom attribute.
 void setAttribute(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, getBuild, getConfiguration, getDesktopCache, getDesktopCacheProvider, getFailoverManager, getIdGenerator, getSessionCache, getSubversion, getUiEngine, getUiFactory, getVersion, loadBuild, sessionDestroyed, sessionDidActivate, sessionWillPassivate, setAppName, setDesktopCacheProvider, setFailoverManager, setIdGenerator, setSessionCache, setUiEngine, setUiFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleWebApp

public SimpleWebApp()
Method Detail

init

public void init(java.lang.Object context,
                 Configuration config)
Description copied from interface: WebAppCtrl
Initializes this Web application.

Specified by:
init in interface WebAppCtrl
Overrides:
init in class AbstractWebApp
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: WebApp
Returns the value of the specified custom attribute.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: WebApp
Sets the value of the specified custom attribute.


removeAttribute

public void removeAttribute(java.lang.String name)
Description copied from interface: WebApp
Removes the specified custom attribute.


getAttributes

public java.util.Map getAttributes()
Description copied from interface: WebApp
Returns a map of custom attributes associated with this object.


getWebApp

public WebApp getWebApp(java.lang.String uripath)
Description copied from interface: WebApp
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..


getDirectory

public java.lang.String getDirectory()
Description copied from interface: Locator
Returns the directory used to resolve the relative path, or null if relative path is not allowed.

Note: if the returned directory is not null, it must end with '/'.


getResource

public java.net.URL getResource(java.lang.String path)
Description copied from interface: WebApp
Returns a URL to the resource that is mapped to a specified path.

Returns:
a URL for reading the resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Description copied from interface: WebApp
Returns the resource located at the named path as an InputStream object.

Returns:
an input stream for reading the resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Description copied from interface: WebApp
Returns the value of the named context-wide initialization parameter, or null if the parameter does not exist.


getInitParameterNames

public java.util.Iterator getInitParameterNames()
Description copied from interface: WebApp
Returns the names of the context's initialization parameters as an Iterator of String objects, or an empty Iterator if the context has no initialization parameters.


getRealPath

public java.lang.String getRealPath(java.lang.String path)
Description copied from interface: WebApp
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 this WebApp.

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: WebApp
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

public java.util.Set getResourcePaths(java.lang.String path)
Description copied from interface: WebApp
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/"}.


getNativeContext

public java.lang.Object getNativeContext()
Description copied from interface: WebApp
Returns the native application context, or null if not available.

The returned object depends on the Web container. If it is based Java servlet container, an instance of javax.servlet.Servletcontext is returned.



Copyright © 2005-2009 Potix Corporation. All Rights Reserved.