|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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(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(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(CharSequence javascript,
String id)
Renders javascript code to the response, if the javascript has not already been rendered. |
void |
renderOnDomReadyJavaScript(String javascript)
Renders javascript that is executed right after the DOM is built, before external resources (e.g. images) are loaded. |
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. |
| Methods inherited from class org.apache.wicket.markup.html.DecoratingHeaderResponse |
|---|
getRealResponse, getResponse, isClosed, markRendered, 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(Set<ResourceReferenceAndStringData> alreadyRendered,
BasicGroupingKey key,
HttpAggregatingResourceReferenceCollection coll)
AbstractResourceAggregatingHeaderResponseAbstractResourceAggregatingHeaderResponse.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 IResource), 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(List<ResourceReferenceAndStringData> allTopLevelReferences)
AbstractResourceAggregatingHeaderResponseAbstractResourceAggregatingHeaderResponse.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)
AbstractResourceAggregatingHeaderResponseAbstractResourceAggregatingHeaderResponse, 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)
AbstractResourceAggregatingHeaderResponseAbstractResourceAggregatingHeaderResponse.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(CharSequence javascript,
String id)
IHeaderResponsescript tags will be added to the output.
renderJavaScript in interface IHeaderResponserenderJavaScript in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>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(String javascript)
IHeaderResponse
renderOnDomReadyJavaScript in interface IHeaderResponserenderOnDomReadyJavaScript in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
public void renderOnEventJavaScript(String target,
String event,
String javascript)
IHeaderResponse
renderOnEventJavaScript in interface IHeaderResponserenderOnEventJavaScript in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>public void renderOnLoadJavaScript(String javascript)
IHeaderResponse
renderOnLoadJavaScript in interface IHeaderResponserenderOnLoadJavaScript in class AbstractResourceAggregatingHeaderResponse<HttpAggregatingResourceReferenceCollection,BasicGroupingKey>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||