Package org.apache.wicket.markup.head
Class ResourceAggregator
- java.lang.Object
-
- org.apache.wicket.markup.html.DecoratingHeaderResponse
-
- org.apache.wicket.markup.head.ResourceAggregator
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IHeaderResponse
public class ResourceAggregator extends DecoratingHeaderResponse
ResourceAggregator
implements resource dependencies, resource bundles and sorting of resources. During the rendering of components, allHeaderItem
s are recorded and processed at the end.- Author:
- papegaaij
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceAggregator.RecordedHeaderItem
Contains information about anHeaderItem
that must be rendered.static class
ResourceAggregator.RecordedHeaderItemLocation
The location in which aHeaderItem
is added, consisting of the component/behavior that added the item, the index in the list for that component/behavior at which the item was added and the index in the request.
-
Constructor Summary
Constructors Constructor Description ResourceAggregator(IHeaderResponse real)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Mark Header rendering is completed and subsequent usage will be ignored.void
markRendered(Object object)
Overridden to keep track of the currently rendered component.protected HeaderItem
preserveCssDetails(CssReferenceHeaderItem item, CssReferenceHeaderItem bundle)
Preserves the resource reference details for CSS resource replacements.protected HeaderItem
preserveDetails(HeaderItem item, HeaderItem bundle)
Preserves the resource reference details for resource replacements.void
render(HeaderItem item)
Renders the givenHeaderItem
to the response if none of its tokens has been rendered before.boolean
wasRendered(Object object)
Overridden to keep track of the currently rendered component.-
Methods inherited from class org.apache.wicket.markup.html.DecoratingHeaderResponse
getRealResponse, getResponse, isClosed
-
-
-
-
Constructor Detail
-
ResourceAggregator
public ResourceAggregator(IHeaderResponse real)
Construct.- Parameters:
real
-
-
-
Method Detail
-
wasRendered
public boolean wasRendered(Object object)
Overridden to keep track of the currently rendered component.- Specified by:
wasRendered
in interfaceIHeaderResponse
- Overrides:
wasRendered
in classDecoratingHeaderResponse
- Parameters:
object
- Object that is queried to be rendered- Returns:
- Whether the object has been marked as rendered during the request
- See Also:
Component.internalRenderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
-
markRendered
public void markRendered(Object object)
Overridden to keep track of the currently rendered component.- Specified by:
markRendered
in interfaceIHeaderResponse
- Overrides:
markRendered
in classDecoratingHeaderResponse
- Parameters:
object
- object to be marked as rendered.- See Also:
Component.internalRenderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
-
render
public void render(HeaderItem item)
Description copied from interface:IHeaderResponse
Renders the givenHeaderItem
to the response if none of its tokens has been rendered before.Automatically marks all item's tokens as rendered.
- Specified by:
render
in interfaceIHeaderResponse
- Overrides:
render
in classDecoratingHeaderResponse
- Parameters:
item
- The item to render.- See Also:
IHeaderResponse.markRendered(Object)
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIHeaderResponse
- Overrides:
close
in classDecoratingHeaderResponse
-
preserveDetails
protected HeaderItem preserveDetails(HeaderItem item, HeaderItem bundle)
Preserves the resource reference details for resource replacements. For example if CSS resource with media screen is replaced withWebApplication.addResourceReplacement(org.apache.wicket.request.resource.CssResourceReference, org.apache.wicket.request.resource.ResourceReference)
then the replacement will will inherit the media attribute- Parameters:
item
- The replaced header itembundle
- The bundle that represents the replacement- Returns:
- the bundle with the preserved details
-
preserveCssDetails
protected HeaderItem preserveCssDetails(CssReferenceHeaderItem item, CssReferenceHeaderItem bundle)
Preserves the resource reference details for CSS resource replacements. For example if CSS resource with media screen is replaced withWebApplication.addResourceReplacement(org.apache.wicket.request.resource.CssResourceReference, org.apache.wicket.request.resource.ResourceReference)
then the replacement will will inherit the media attribute- Parameters:
item
- The replaced header itembundle
- The bundle that represents the replacement- Returns:
- the bundle with the preserved details
-
-