org.apache.wicket.resource.dependencies
Class ResourceReferenceDependencyInjectingHeaderResponse

java.lang.Object
  extended by org.apache.wicket.markup.html.DecoratingHeaderResponse
      extended by org.apache.wicket.resource.dependencies.ResourceReferenceDependencyInjectingHeaderResponse
All Implemented Interfaces:
IHeaderResponse

public class ResourceReferenceDependencyInjectingHeaderResponse
extends DecoratingHeaderResponse

A header response that can be used by IHeaderResponseDecorator to wrap another IHeaderResponse. This response will take all references (js and css) and pass them to the IResourceReferenceDependencyConfigurationService to get the dependency tree populated. After this, it will call through to the wrapped header response and render the tree in the child-first dependency order so that all dependencies are guaranteed to be satisfied before this reference is rendered.

Author:
Jeremy Thomerson

Constructor Summary
ResourceReferenceDependencyInjectingHeaderResponse(IHeaderResponse decorated)
          If you call this constructor, you MUST override getConfigurationService().
ResourceReferenceDependencyInjectingHeaderResponse(IHeaderResponse decorated, IResourceReferenceDependencyConfigurationService configurator)
          Construct this header response with a configuration service that will be used to find dependencies.
 
Method Summary
 IResourceReferenceDependencyConfigurationService getConfigurationService()
          If you did not supply a non-null configuration service in the constructor, you must override this to return a configuration service to be used by this response.
protected  void render(AbstractResourceDependentResourceReference parent)
          The method responsible for rendering the resource references.
 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 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.
 
Methods inherited from class org.apache.wicket.markup.html.DecoratingHeaderResponse
close, getRealResponse, getResponse, isClosed, markRendered, renderCSSReference, renderCSSReference, renderJavascript, renderJavascriptReference, renderJavascriptReference, renderOnDomReadyJavascript, renderOnEventJavascript, renderOnLoadJavascript, renderString, wasRendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceReferenceDependencyInjectingHeaderResponse

public ResourceReferenceDependencyInjectingHeaderResponse(IHeaderResponse decorated)
If you call this constructor, you MUST override getConfigurationService().

Parameters:
decorated - the response you are decorating

ResourceReferenceDependencyInjectingHeaderResponse

public ResourceReferenceDependencyInjectingHeaderResponse(IHeaderResponse decorated,
                                                          IResourceReferenceDependencyConfigurationService configurator)
Construct this header response with a configuration service that will be used to find dependencies.

Parameters:
decorated - the response you are decorating
configurator - the configuration service
Method Detail

getConfigurationService

public IResourceReferenceDependencyConfigurationService getConfigurationService()
If you did not supply a non-null configuration service in the constructor, you must override this to return a configuration service to be used by this response.

Returns:
the configuration service used by this response

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
Overrides:
renderCSSReference in class DecoratingHeaderResponse
Parameters:
reference - resource reference pointing to 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
Overrides:
renderCSSReference in class DecoratingHeaderResponse
Parameters:
reference - resource reference pointing to the CSS resource
media - the media type for this CSS ("print", "screen", etc.)

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
Overrides:
renderJavascriptReference in class DecoratingHeaderResponse
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
Overrides:
renderJavascriptReference in class DecoratingHeaderResponse
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)

render

protected void render(AbstractResourceDependentResourceReference parent)
The method responsible for rendering the resource references. This should happen child-first so that the dependencies (children) of the given parent are loaded first, thereby satisfying the dependencies of the supplied parent. Typically the actual rendering will happen on the response that this response is wrapping. The default implementation does all rendering to the wrapped response. The default implementation delegates the actual rendering to the AbstractResourceDependentResourceReference itself.

Parameters:
parent - the reference that needs itself and all dependencies to be rendered


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