|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.markup.html.DecoratingHeaderResponse org.apache.wicket.resource.aggregation.AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey> org.apache.wicket.examples.resourcedecoration.GroupingHeaderResponse
public class GroupingHeaderResponse
A IHeaderResponse
decorator that groups the resources by type (css or js) and by
custom groups
Constructor Summary | |
---|---|
GroupingHeaderResponse(IHeaderResponse real)
Construct. |
Method Summary | |
---|---|
protected BasicGroupingKey |
newGroupingKey(ResourceReferenceAndStringData ref)
This key is what is used to determine how to group (or aggregate) your resources. |
protected HttpAggregatingResourceReferenceCollection |
newResourceReferenceCollection(BasicGroupingKey key)
creates a ResourceReferenceCollection. |
protected void |
onAllCollectionsRendered(java.util.List<ResourceReferenceAndStringData> allTopLevelReferences)
After all the collections have been rendered, we call this callback so your subclass can add any other logic as needed. |
protected void |
renderCollection(java.util.Set<ResourceReferenceAndStringData> alreadyRendered,
BasicGroupingKey key,
HttpAggregatingResourceReferenceCollection coll)
When the entire hierarchy has been traversed and AbstractResourceAggregatingHeaderResponse.close() is called, we loop through
the grouped collections and render them in this method. |
void |
renderJavaScript(java.lang.CharSequence javascript,
java.lang.String id)
Renders javascript code to the response, if the javascript has not already been rendered. |
void |
renderOnDomReadyJavaScript(java.lang.String javascript)
Renders javascript that is executed right after the DOM is built, before external resources (e.g. |
void |
renderOnEventJavaScript(java.lang.String target,
java.lang.String event,
java.lang.String javascript)
Renders javascript that is executed after the given event happens on specified target |
void |
renderOnLoadJavaScript(java.lang.String javascript)
Renders javascript that is executed after the entire page is loaded. |
Methods inherited from class org.apache.wicket.resource.aggregation.AbstractResourceAggregatingHeaderResponse |
---|
close, getGroupingKeyComparator, render, renderCSSReference, renderCSSReference, renderCSSReference, renderCSSReference, renderIfNotAlreadyRendered, renderJavaScriptReference, renderJavaScriptReference, renderJavaScriptReference, renderJavaScriptReference |
Methods inherited from class org.apache.wicket.markup.html.DecoratingHeaderResponse |
---|
getRealResponse, getResponse, isClosed, markRendered, renderCSS, renderCSSReference, renderCSSReference, renderCSSReference, renderJavaScriptReference, renderJavaScriptReference, renderJavaScriptReference, renderJavaScriptReference, renderJavaScriptReference, renderString, wasRendered |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GroupingHeaderResponse(IHeaderResponse real)
real
- Method Detail |
---|
protected void renderCollection(java.util.Set<ResourceReferenceAndStringData> alreadyRendered, BasicGroupingKey key, HttpAggregatingResourceReferenceCollection coll)
AbstractResourceAggregatingHeaderResponse
AbstractResourceAggregatingHeaderResponse.close()
is called, we loop through
the grouped collections and render them in this method. This method is typically overridden
to render your collection how you want to render them.
For instance, if you want to aggregate your groups into a single HTTP request, you can
override this method, create the URL to your aggregation servlet (or Resource
), and
then call getRealResponse().renderJavaScriptReference(yourUrl), or the appropriate
method to render the URL for a group of CSS references.
renderCollection
in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
alreadyRendered
- a set of resource references that have already been rendered in other groupskey
- they grouping key for this groupcoll
- the collection of resource references to renderprotected void onAllCollectionsRendered(java.util.List<ResourceReferenceAndStringData> allTopLevelReferences)
AbstractResourceAggregatingHeaderResponse
AbstractResourceAggregatingHeaderResponse.renderCollection(Set, Object, ResourceReferenceCollection)
method might have
rendered only a YUI constructor that loaded all the JS files for each group. Then, you need
to loop through the references again, and render any JS inside a sandboxed YUI.use()
statement. You would render those here by creating the YUI.use statement, and call
getHeaderResponse().renderJavaScript(yourJS, null)
onAllCollectionsRendered
in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
allTopLevelReferences
- all the references that were rendered by the developersprotected HttpAggregatingResourceReferenceCollection newResourceReferenceCollection(BasicGroupingKey key)
AbstractResourceAggregatingHeaderResponse
AbstractResourceAggregatingHeaderResponse
, override this method.
Note that because of the generics definition, you will probably have to cast to R. R is the
parameter used when creating your subclass defining the type of ResourceReferenceCollection
this returns and is passed into all methods that take a ResourceReferenceCollection
newResourceReferenceCollection
in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
key
- the grouping key that will be used for this collection. all references added to it
will have the same key
protected BasicGroupingKey newGroupingKey(ResourceReferenceAndStringData ref)
AbstractResourceAggregatingHeaderResponse
AbstractResourceAggregatingHeaderResponse.getGroupingKeyComparator()
and return a valid comparator that sorts
keys in the order you want references rendered.
newGroupingKey
in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
ref
- the resource reference with associated data that came from the render*Reference
methods
public void renderJavaScript(java.lang.CharSequence javascript, java.lang.String id)
IHeaderResponse
script
tags will be added to the output.
renderJavaScript
in interface IHeaderResponse
renderJavaScript
in class DecoratingHeaderResponse
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.public void renderOnDomReadyJavaScript(java.lang.String javascript)
IHeaderResponse
renderOnDomReadyJavaScript
in interface IHeaderResponse
renderOnDomReadyJavaScript
in class DecoratingHeaderResponse
public void renderOnEventJavaScript(java.lang.String target, java.lang.String event, java.lang.String javascript)
IHeaderResponse
renderOnEventJavaScript
in interface IHeaderResponse
renderOnEventJavaScript
in class DecoratingHeaderResponse
public void renderOnLoadJavaScript(java.lang.String javascript)
IHeaderResponse
renderOnLoadJavaScript
in interface IHeaderResponse
renderOnLoadJavaScript
in class DecoratingHeaderResponse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |