org.hippoecm.hst.core.component
Class HstResourceResponseImpl

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.hippoecm.hst.core.component.HstResourceResponseImpl
All Implemented Interfaces:
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse, HstResponse

public class HstResourceResponseImpl
extends javax.servlet.http.HttpServletResponseWrapper
implements HstResponse

Factory implementation for creating HTTP Response Wrappers for resource response

Version:
$Id: HstResourceResponseImpl.java 30375 2011-09-23 12:45:37Z aschrijvers $

Field Summary
protected  HstComponentWindow componentWindow
           
protected  String serveResourcePath
           
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
HstResourceResponseImpl(javax.servlet.http.HttpServletResponse response, HstComponentWindow componentWindow)
           
 
Method Summary
 void addHeadElement(Element element, String keyHint)
          Adds an header element property to the response.
 void addPreamble(Comment comment)
          Add a preamble comment node, which gets rendered at the beginning of the render window.
 boolean containsHeadElement(String keyHint)
          Asks if a property exists already or not.
 HstURL createActionURL()
          Creates a HST Action URL targeting the HstComponent.
 Comment createComment(String comment)
          Creates a comment element
 HstURL createComponentRenderingURL()
          Creates a HST component rendering URL targeting a specific HstComponent
 Element createElement(String tagName)
          Creates an element of the type specified to be used in the #addProperty(String, Element) method.
 HstURL createNavigationalURL(String pathInfo)
          Creates a HST Navigational Render URL
 HstURL createRenderURL()
          Creates a HST Render URL targeting the HstComponent.
 HstURL createResourceURL()
          Creates a HST Resource URL targeting the current HstComponent.
 HstURL createResourceURL(String referenceNamespace)
          Creates a HST Resource URL targeting the HstComponent indicated by referenceNamespace.
 void flushChildContent(String name)
          Flushes the buffer of child window.
 void forward(String pathInfo)
          Forwards the page request to pathInfo.
 List<String> getChildContentNames()
          Returns the flushable child content window names.
 List<Element> getHeadElements()
          Retrieves header element list.
 String getNamespace()
          The value returned by this method should be prefixed or appended to elements, such as JavaScript variables or function names, to ensure they are unique in the context of the HST-managed page.
 String getServeResourcePath()
           
 Element getWrapperElement()
          Returns the wrapper element for the rendered content
 boolean isRendererSkipped()
          For single /subtree component rendering mode that has HstComponentInfo.isStandalone() equal to false, this check can be used whether some HstComponent won't get its renderer called.
 void setRenderParameter(String key, String value)
          Sets a String parameter for the rendering phase.
 void setRenderParameter(String key, String[] values)
          Sets a String parameter for the rendering phase.
 void setRenderParameters(Map<String,String[]> parameters)
          Sets a parameter map for the render request.
 void setRenderPath(String renderPath)
          Sets the renderPath dynamically.
 void setServeResourcePath(String serveResourcePath)
          Sets the serveResourcePath dynamically.
 void setWrapperElement(Element element)
          Sets wrapper element for the rendered content
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus
 
Methods inherited from class javax.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hippoecm.hst.core.component.HstResponse
addCookie, sendError, sendError, sendRedirect, setStatus
 
Methods inherited from interface javax.servlet.http.HttpServletResponse
addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, setDateHeader, setHeader, setIntHeader, setStatus
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale
 

Field Detail

componentWindow

protected HstComponentWindow componentWindow

serveResourcePath

protected String serveResourcePath
Constructor Detail

HstResourceResponseImpl

public HstResourceResponseImpl(javax.servlet.http.HttpServletResponse response,
                               HstComponentWindow componentWindow)
Method Detail

addHeadElement

public void addHeadElement(Element element,
                           String keyHint)
Description copied from interface: HstResponse
Adds an header element property to the response. If keyHint argument is provided and if a header element with the provided key hint already exists, then the element will be ignored. If the element is null the key is removed from the response. If these header values are intended to be transmitted to the client they should be set before the response is committed.

Specified by:
addHeadElement in interface HstResponse

createElement

public Element createElement(String tagName)
Description copied from interface: HstResponse
Creates an element of the type specified to be used in the #addProperty(String, Element) method.

Specified by:
createElement in interface HstResponse
Parameters:
tagName - the tag name of the element
Returns:
DOM element with the tagName

createComment

public Comment createComment(String comment)
Description copied from interface: HstResponse
Creates a comment element

Specified by:
createComment in interface HstResponse
Parameters:
comment - the comment text
Returns:
Comment DOM element with the text as content

createRenderURL

public HstURL createRenderURL()
Description copied from interface: HstResponse
Creates a HST Render URL targeting the HstComponent.

Specified by:
createRenderURL in interface HstResponse
Returns:

createNavigationalURL

public HstURL createNavigationalURL(String pathInfo)
Description copied from interface: HstResponse
Creates a HST Navigational Render URL

Specified by:
createNavigationalURL in interface HstResponse
Parameters:
pathInfo - the path to be navigated
Returns:

createActionURL

public HstURL createActionURL()
Description copied from interface: HstResponse
Creates a HST Action URL targeting the HstComponent.

Specified by:
createActionURL in interface HstResponse
Returns:

createResourceURL

public HstURL createResourceURL()
Description copied from interface: HstResponse
Creates a HST Resource URL targeting the current HstComponent.

Specified by:
createResourceURL in interface HstResponse
Returns:

createResourceURL

public HstURL createResourceURL(String referenceNamespace)
Description copied from interface: HstResponse
Creates a HST Resource URL targeting the HstComponent indicated by referenceNamespace.

Specified by:
createResourceURL in interface HstResponse
Returns:

createComponentRenderingURL

public HstURL createComponentRenderingURL()
Description copied from interface: HstResponse
Creates a HST component rendering URL targeting a specific HstComponent

Specified by:
createComponentRenderingURL in interface HstResponse
Returns:
a component rendering ULR

getNamespace

public String getNamespace()
Description copied from interface: HstResponse
The value returned by this method should be prefixed or appended to elements, such as JavaScript variables or function names, to ensure they are unique in the context of the HST-managed page. The namespace value must be constant for the lifetime of the HstComponentWindow.

Specified by:
getNamespace in interface HstResponse
Returns:

getHeadElements

public List<Element> getHeadElements()
Description copied from interface: HstResponse
Retrieves header element list. This method is supposed to be invoked by the parent HstComponent to render some header tag elements in a non-portal environment. Under portal environment, this method is not supposed to be invoked because the header tag elements should be written by the portal. Under portal environment, the HstComponents can write some body tag fragments only. If a HstComponent contributes some header tag elements by invoking HstResponse.addHeadElement(Element, String), then the portal will write all the merged head tag elements finally.

Specified by:
getHeadElements in interface HstResponse
Returns:
List with head element items

setRenderParameter

public void setRenderParameter(String key,
                               String value)
Description copied from interface: HstResponse
Sets a String parameter for the rendering phase. These parameters will be accessible in all sub-sequent render calls via the HstRequest.getParameter call until a request is targeted to the Hst component. This method replaces all parameters with the given key. The given parameter do not need to be encoded prior to calling this method.

Specified by:
setRenderParameter in interface HstResponse
Parameters:
key - key of the render parameter
value - value of the render parameter

setRenderParameter

public void setRenderParameter(String key,
                               String[] values)
Description copied from interface: HstResponse
Sets a String parameter for the rendering phase. These parameters will be accessible in all sub-sequent render calls via the HstRequest.getParameter call until a request is targeted to the Hst component. This method replaces all parameters with the given key. The given parameter do not need to be encoded prior to calling this method.

Specified by:
setRenderParameter in interface HstResponse
Parameters:
key - key of the render parameter
values - values of the render parameters

setRenderParameters

public void setRenderParameters(Map<String,String[]> parameters)
Description copied from interface: HstResponse
Sets a parameter map for the render request. All previously set render parameters are cleared. These parameters will be accessible in all sub-sequent renderinrg phase via the HstRequest.getParameter call until a new request is targeted to the Hst component. The given parameters do not need to be encoded prior to calling this method. The Hst component should not modify the map any further after calling this method.

Specified by:
setRenderParameters in interface HstResponse

containsHeadElement

public boolean containsHeadElement(String keyHint)
Description copied from interface: HstResponse
Asks if a property exists already or not. This method checks all the parent component reponses have the property.

Specified by:
containsHeadElement in interface HstResponse
Returns:

setRenderPath

public void setRenderPath(String renderPath)
Description copied from interface: HstResponse
Sets the renderPath dynamically. Normally, the renderPath is set in the configuration, but it can be set dynamically in the HstComponent.doBeforeRender(HstRequest, HstResponse) method.

Specified by:
setRenderPath in interface HstResponse

setServeResourcePath

public void setServeResourcePath(String serveResourcePath)
Description copied from interface: HstResponse
Sets the serveResourcePath dynamically. Normally, the serveResourcePath is set in the configuration, but it can be set dynamically in the HstComponent.doBeforeServeResource(HstRequest, HstResponse) method.

Specified by:
setServeResourcePath in interface HstResponse

getServeResourcePath

public String getServeResourcePath()

flushChildContent

public void flushChildContent(String name)
                       throws IOException
Description copied from interface: HstResponse
Flushes the buffer of child window.

Note: the child content can be flushed only once. If it is already flushed, then the next invocations will not make any effect.

Specified by:
flushChildContent in interface HstResponse
Parameters:
name - the name of the child window
Throws:
IOException

getChildContentNames

public List<String> getChildContentNames()
Description copied from interface: HstResponse
Returns the flushable child content window names.

Specified by:
getChildContentNames in interface HstResponse
Returns:

forward

public void forward(String pathInfo)
             throws IOException
Description copied from interface: HstResponse
Forwards the page request to pathInfo.

Only in HstComponent.doBeforeRender(HstRequest, HstResponse), the invocation on this method will be effective. If the invocation on this method is done in a view page during render phase, the invocation will be just ignored with no operation.

Specified by:
forward in interface HstResponse
Parameters:
pathInfo - the path info to forward. It should start with a "/" and is relative to the root of your hst sitemap
Throws:
IOException - If the response was committed

getWrapperElement

public Element getWrapperElement()
Description copied from interface: HstResponse
Returns the wrapper element for the rendered content

Specified by:
getWrapperElement in interface HstResponse
Returns:

addPreamble

public void addPreamble(Comment comment)
Description copied from interface: HstResponse
Add a preamble comment node, which gets rendered at the beginning of the render window.

Specified by:
addPreamble in interface HstResponse
Parameters:
comment - the comment node

setWrapperElement

public void setWrapperElement(Element element)
Description copied from interface: HstResponse
Sets wrapper element for the rendered content

Specified by:
setWrapperElement in interface HstResponse

isRendererSkipped

public boolean isRendererSkipped()
Description copied from interface: HstResponse
For single /subtree component rendering mode that has HstComponentInfo.isStandalone() equal to false, this check can be used whether some HstComponent won't get its renderer called. In other words, this is for performance optimization to short-circuit the doBeforeRender for components that won't get rendered any way.

Specified by:
isRendererSkipped in interface HstResponse
Returns:
true when for this HstResponse the renderer won't be invoked


Copyright © 2008-2012 Hippo. All Rights Reserved.