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:
java.io.Closeable
,java.lang.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(java.lang.Object object)
Marks the given object as rendered.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 the tokens of the item has been rendered before.boolean
wasRendered(java.lang.Object object)
Returns whether the given object has been marked as rendered.-
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
-
markRendered
public void markRendered(java.lang.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 interfaceIHeaderResponse
- Overrides:
markRendered
in classDecoratingHeaderResponse
- Parameters:
object
- object to be marked as rendered.
-
wasRendered
public boolean wasRendered(java.lang.Object object)
Description copied from interface:IHeaderResponse
Returns whether the given object has been marked as rendered.- Methods
renderJavaScriptReference
andrenderCSSReference
mark the specifiedResourceReference
as rendered. - Method
renderJavaScript
marks List of two elements (first is javascript body CharSequence and second is id) as rendered. - Method
renderString
marks the whole string as rendered. - Method
markRendered
can be used to mark an arbitrary object as rendered
- 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
- Methods
-
render
public void render(HeaderItem item)
Description copied from interface:IHeaderResponse
Renders the givenHeaderItem
to the response if none of the tokens of the item has been rendered before.- Specified by:
render
in interfaceIHeaderResponse
- Overrides:
render
in classDecoratingHeaderResponse
- Parameters:
item
- The item to render.
-
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- 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
-
-