org.zkoss.web.servlet.dsp
Class ServletDspContext

java.lang.Object
  extended by org.zkoss.web.servlet.dsp.ServletDspContext
All Implemented Interfaces:
DspContext, RequestContext
Direct Known Subclasses:
ExtendletDspContext

public class ServletDspContext
extends java.lang.Object
implements DspContext

A DSP context based on HTTP servlet request and response.

Author:
tomyeh

Constructor Summary
ServletDspContext(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Locator locator)
          Constructor.
ServletDspContext(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.io.Writer out, Locator locator)
          Constructor with the specified writer.
 
Method Summary
 java.lang.String encodeURL(java.lang.String uri)
          Returns the encoded URL.
 Locator getLocator()
          Returns the locator for loading resources, such as taglib.
 java.io.Writer getOut()
          Returns the writer, never null.
 javax.servlet.ServletRequest getRequest()
          Returns the request, or null if not available.
 javax.servlet.ServletResponse getResponse()
          Returns the response, or null if not available.
 javax.servlet.ServletContext getServletContext()
          Returns the request, or null if not available.
 VariableResolver getVariableResolver()
          Returns the variable resolver.
 void include(java.lang.String uri, java.util.Map params)
          Includes the specified URI and render the result to the specified output.
 boolean isIncluded()
          Returns whether this page is included.
 void setContentType(java.lang.String ctype)
          Sets the content type of the output.
 void setOut(java.io.Writer out)
          Changes the writer of this context to the specified one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletDspContext

public ServletDspContext(javax.servlet.ServletContext ctx,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         Locator locator)
Constructor.

Parameters:
locator - used to locate resources, such as taglib. If null is specified, the locator for the specified servlet context is used. (In other words, we use ServletContextLocator(ctx), if locator is null).

ServletDspContext

public ServletDspContext(javax.servlet.ServletContext ctx,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         java.io.Writer out,
                         Locator locator)
Constructor with the specified writer.

Parameters:
locator - used to locate resources, such as taglib. If null is specified, the locator for the specified servlet context is used. (In other words, we use ServletContextLocator(ctx), if locator is null).
out - the output to generate the result. If null, it is the same as ServletDspContext(ServletContext,HttpServletRequest,HttpServletResponse,Locator) In other words, response.getWriter() is used.
Since:
2.4.1
Method Detail

getLocator

public Locator getLocator()
Description copied from interface: DspContext
Returns the locator for loading resources, such as taglib. You might return null if the page not referencing external resources.

To load the resource from a web application, use ServletContextLocator To load the resource from class path, use org.zkoss.util.resource.Resources.getDefault().

Specified by:
getLocator in interface DspContext

setContentType

public void setContentType(java.lang.String ctype)
Description copied from interface: DspContext
Sets the content type of the output.

Specified by:
setContentType in interface DspContext

setOut

public void setOut(java.io.Writer out)
Description copied from interface: DspContext
Changes the writer of this context to the specified one.

Specified by:
setOut in interface DspContext
Parameters:
out - the new writer. If null, it is restored to the default one.

encodeURL

public java.lang.String encodeURL(java.lang.String uri)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
Description copied from interface: DspContext
Returns the encoded URL. The returned URL is also encoded with HttpServletResponse.encodeURL.

Specified by:
encodeURL in interface DspContext
Parameters:
uri - it must be empty or starts with "/". It might contain "*" for current browser code and Locale.
Returns:
the complete URL (excluding the machine name). It includes the context path and the servlet to interpret this extended resource.
Throws:
javax.servlet.ServletException
java.io.IOException

include

public void include(java.lang.String uri,
                    java.util.Map params)
             throws javax.servlet.ServletException,
                    java.io.IOException
Description copied from interface: DspContext
Includes the specified URI and render the result to the specified output.

Specified by:
include in interface DspContext
Parameters:
uri - the URI to include. It is OK to relevant (without leading '/'). If starts with "/", the context path of request is assumed. To reference to foreign context, use "~ctx/" where ctx is the context path of the foreign context (without leading '/').
params - a map of parameters, or null to ignore. The map is passed thru the request attribute called arg.
Throws:
javax.servlet.ServletException
java.io.IOException

isIncluded

public boolean isIncluded()
Description copied from interface: DspContext
Returns whether this page is included.

Specified by:
isIncluded in interface DspContext

getOut

public java.io.Writer getOut()
                      throws java.io.IOException
Description copied from interface: RequestContext
Returns the writer, never null.

Specified by:
getOut in interface RequestContext
Throws:
java.io.IOException

getRequest

public javax.servlet.ServletRequest getRequest()
Description copied from interface: RequestContext
Returns the request, or null if not available.

Specified by:
getRequest in interface RequestContext

getResponse

public javax.servlet.ServletResponse getResponse()
Description copied from interface: RequestContext
Returns the response, or null if not available.

Specified by:
getResponse in interface RequestContext

getServletContext

public javax.servlet.ServletContext getServletContext()
Description copied from interface: RequestContext
Returns the request, or null if not available.

Specified by:
getServletContext in interface RequestContext

getVariableResolver

public VariableResolver getVariableResolver()
Description copied from interface: RequestContext
Returns the variable resolver.

Specified by:
getVariableResolver in interface RequestContext


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo