Author: jrthomerson
Date: Thu Dec 16 17:02:42 2010
New Revision: 1050058
URL: http://svn.apache.org/viewvc?rev=1050058&view=rev
Log:
add more flexibility for subclasses of
HeaderResponseContainerFilteringHeaderResponse
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/filtering/HeaderResponseContainerFilteringHeaderResponse.java
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/filtering/HeaderResponseContainerFilteringHeaderResponse.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/filtering/HeaderResponseContainerFilteringHeaderResponse.java?rev=1050058&r1=1050057&r2=1050058&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/filtering/HeaderResponseContainerFilteringHeaderResponse.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/filtering/HeaderResponseContainerFilteringHeaderResponse.java
Thu Dec 16 17:02:42 2010
@@ -378,15 +378,48 @@ public class HeaderResponseContainerFilt
log.warn("css was rendered to the filtering header response,
but did not match any filters, so it was effectively lost. Make sure that you
have filters that accept every possible case or else configure a default filter
that returns true to all acceptance tests");
}
+
+ /**
+ * If subclasses of this class have special cases where they force
something into a particular
+ * bucket, regardless of the filters, they can create a Runnable that
renders to the real
+ * response, and pass it to this method with the name of the filter
(bucket) that they want it
+ * to appear in.
+ *
+ * Example: <code>
+ public void renderJavascriptIntoHead(final String js, final
String id) {
+ runWithFilter(new Runnable() {
+ public void run()
+ {
+ getRealResponse().renderJavascript(js,
id);
+ }
+ }, "headerBucket");
+ }
+ * </code>
+ *
+ * @param runnable
+ * the runnable that renders to the real response.
+ * @param filterName
+ * the name of the filter bucket that you want the runnable
to render into
+ */
+ protected final void runWithFilter(Runnable runnable, String filterName)
+ {
+ run(runnable, responseFilterMap.get(filterName));
+ }
+
private void run(Runnable runnable, IHeaderResponseFilter filter)
{
+ run(runnable, responseFilterMap.get(filter.getName()));
+ }
+
+ private void run(Runnable runnable, Response response)
+ {
if (AjaxRequestTarget.get() != null)
{
// we're in an ajax request, so we don't filter and
separate stuff....
runnable.run();
return;
}
- Response original =
RequestCycle.get().setResponse(responseFilterMap.get(filter.getName()));
+ Response original = RequestCycle.get().setResponse(response);
try
{
runnable.run();