org.apache.wicket.markup.html
Class DecoratingHeaderResponse

java.lang.Object
  extended by org.apache.wicket.markup.html.DecoratingHeaderResponse
All Implemented Interfaces:
IHeaderResponse
Direct Known Subclasses:
AbstractResourceAggregatingHeaderResponse, HeaderResponseContainerFilteringHeaderResponse, ResourceReferenceDependencyInjectingHeaderResponse

public abstract class DecoratingHeaderResponse
extends Object
implements IHeaderResponse

This is simply a helper implementation of IHeaderResponse that really delegates all of its method calls to the IHeaderResponse that is passed into the constructor. It is defined as abstract because it's only meant to be extended and not used a la carte. You can extend it and override only the methods that you want to change the functionality of.

Author:
Jeremy Thomerson
See Also:
IHeaderResponseDecorator, IHeaderResponse

Constructor Summary
DecoratingHeaderResponse(IHeaderResponse real)
          Create a header response that simply delegates all methods to the one that is passed in here.
 
Method Summary
 void close()
          Mark Header rendering is completed and subsequent usage will be ignored.
protected  IHeaderResponse getRealResponse()
          Returns the actual response being decorated for subclasses to be able to pass it off to other objects if they need to do so.
 Response getResponse()
          Returns the response that can be used to write arbitrary text to the head section.
 boolean isClosed()
           
 void markRendered(Object object)
          Marks the given object as rendered.
 void renderCSSReference(ResourceReference reference)
          Writes a CSS reference, if the specified reference hasn't been rendered yet.
 void renderCSSReference(ResourceReference reference, String media)
          Writes a CSS reference, if the specified reference hasn't been rendered yet.
 void renderCSSReference(String url)
          Writes a CSS reference, if the specified reference hasn't been rendered yet.
 void renderCSSReference(String url, String media)
          Writes a CSS reference, if the specified reference hasn't been rendered yet.
 void renderJavascript(CharSequence javascript, String id)
          Renders javascript code to the response, if the javascript has not already been rendered.
 void renderJavascriptReference(ResourceReference reference)
          Writes a javascript reference, if the specified reference hasn't been rendered yet.
 void renderJavascriptReference(ResourceReference reference, String id)
          Writes a javascript reference, if the specified reference hasn't been rendered yet.
 void renderJavascriptReference(String url)
          Writes a javascript reference, if the specified reference hasn't been rendered yet.
 void renderJavascriptReference(String url, String id)
          Writes a javascript reference, if the specified reference hasn't been rendered yet.
 void renderOnDomReadyJavascript(String javascript)
          Renders javascript that is executed right after the DOM is built, before external resources (e.g.
 void renderOnEventJavascript(String target, String event, String javascript)
          Renders javascript that is executed after the given event happens on specified target
 void renderOnLoadJavascript(String javascript)
          Renders javascript that is executed after the entire page is loaded.
 void renderString(CharSequence string)
          Renders an arbitrary string to the header.
 boolean wasRendered(Object object)
          Returns whether the given object has been marked as rendered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecoratingHeaderResponse

public DecoratingHeaderResponse(IHeaderResponse real)
Create a header response that simply delegates all methods to the one that is passed in here.

Parameters:
real - the actual response that this class delegates to by default
Method Detail

getRealResponse

protected final IHeaderResponse getRealResponse()
Returns the actual response being decorated for subclasses to be able to pass it off to other objects if they need to do so.

Returns:
the actual wrapped IHeaderResponse

renderJavascriptReference

public void renderJavascriptReference(ResourceReference reference)
Description copied from interface: IHeaderResponse
Writes a javascript reference, if the specified reference hasn't been rendered yet.

Specified by:
renderJavascriptReference in interface IHeaderResponse
Parameters:
reference - resource reference pointing to the javascript resource

renderJavascriptReference

public void renderJavascriptReference(ResourceReference reference,
                                      String id)
Description copied from interface: IHeaderResponse
Writes a javascript reference, if the specified reference hasn't been rendered yet.

Specified by:
renderJavascriptReference in interface IHeaderResponse
Parameters:
reference - resource reference pointing to the javascript resource
id - id that will be used to filter duplicate reference (it's still filtered by URL too)

renderJavascriptReference

public void renderJavascriptReference(String url)
Description copied from interface: IHeaderResponse
Writes a javascript reference, if the specified reference hasn't been rendered yet.

Specified by:
renderJavascriptReference in interface IHeaderResponse
Parameters:
url - url of the the javascript resource

renderJavascriptReference

public void renderJavascriptReference(String url,
                                      String id)
Description copied from interface: IHeaderResponse
Writes a javascript reference, if the specified reference hasn't been rendered yet.

Specified by:
renderJavascriptReference in interface IHeaderResponse
Parameters:
url - url of the the javascript resource
id - id that will be used to filter duplicate reference (it's still filtered by URL too)

renderJavascript

public void renderJavascript(CharSequence javascript,
                             String id)
Description copied from interface: IHeaderResponse
Renders javascript code to the response, if the javascript has not already been rendered. the necessary surrounding script tags will be added to the output.

Specified by:
renderJavascript in interface IHeaderResponse
Parameters:
javascript - javascript content to be rendered.
id - unique id for the javascript element. This can be null, however in that case the ajax header contribution can't detect duplicate script fragments.

renderCSSReference

public void renderCSSReference(ResourceReference reference)
Description copied from interface: IHeaderResponse
Writes a CSS reference, if the specified reference hasn't been rendered yet.

Specified by:
renderCSSReference in interface IHeaderResponse
Parameters:
reference - resource reference pointing to the CSS resource

renderCSSReference

public void renderCSSReference(String url)
Description copied from interface: IHeaderResponse
Writes a CSS reference, if the specified reference hasn't been rendered yet.

Specified by:
renderCSSReference in interface IHeaderResponse
Parameters:
url - url of the CSS resource

renderCSSReference

public void renderCSSReference(ResourceReference reference,
                               String media)
Description copied from interface: IHeaderResponse
Writes a CSS reference, if the specified reference hasn't been rendered yet.

Specified by:
renderCSSReference in interface IHeaderResponse
Parameters:
reference - resource reference pointing to the CSS resource
media - the media type for this CSS ("print", "screen", etc.)

renderCSSReference

public void renderCSSReference(String url,
                               String media)
Description copied from interface: IHeaderResponse
Writes a CSS reference, if the specified reference hasn't been rendered yet.

Specified by:
renderCSSReference in interface IHeaderResponse
Parameters:
url - url of the CSS resource
media - the media type for this CSS ("print", "screen", etc.)

renderString

public void renderString(CharSequence string)
Description copied from interface: IHeaderResponse
Renders an arbitrary string to the header. The string is only rendered if the same string hasn't been rendered before.

Note: This method is kind of dangerous as users are able to write to the output whatever they like.

Specified by:
renderString in interface IHeaderResponse
Parameters:
string - string to be rendered to head

markRendered

public void markRendered(Object object)
Description copied from interface: IHeaderResponse
Marks the given object as rendered. The object can be anything (string, resource reference, etc...). The purpose of this function is to allow user to manually keep track of rendered items. This can be useful for items that are expensive to generate (like interpolated text).

Specified by:
markRendered in interface IHeaderResponse
Parameters:
object - object to be marked as rendered.

wasRendered

public boolean wasRendered(Object object)
Description copied from interface: IHeaderResponse
Returns whether the given object has been marked as rendered.

Specified by:
wasRendered in interface IHeaderResponse
Parameters:
object - Object that is queried to be rendered
Returns:
Whether the object has been marked as rendered during the request

getResponse

public Response getResponse()
Description copied from interface: IHeaderResponse
Returns the response that can be used to write arbitrary text to the head section.

Note: This method is kind of dangerous as users are able to write to the output whatever they like.

Specified by:
getResponse in interface IHeaderResponse
Returns:
Response

renderOnDomReadyJavascript

public void renderOnDomReadyJavascript(String javascript)
Description copied from interface: IHeaderResponse
Renders javascript that is executed right after the DOM is built, before external resources (e.g. images) are loaded.

Specified by:
renderOnDomReadyJavascript in interface IHeaderResponse

renderOnLoadJavascript

public void renderOnLoadJavascript(String javascript)
Description copied from interface: IHeaderResponse
Renders javascript that is executed after the entire page is loaded.

Specified by:
renderOnLoadJavascript in interface IHeaderResponse

renderOnEventJavascript

public void renderOnEventJavascript(String target,
                                    String event,
                                    String javascript)
Description copied from interface: IHeaderResponse
Renders javascript that is executed after the given event happens on specified target

Specified by:
renderOnEventJavascript in interface IHeaderResponse

close

public void close()
Description copied from interface: IHeaderResponse
Mark Header rendering is completed and subsequent usage will be ignored. If some kind of buffering is used internally, this action will mark that the contents has to be flushed out.

Specified by:
close in interface IHeaderResponse

isClosed

public boolean isClosed()
Specified by:
isClosed in interface IHeaderResponse
Returns:
if header rendering is completed and subsequent usage will be ignored


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.