/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wicket.markup.html;

import java.io.Serializable;

import wicket.ResourceReference;
import wicket.Response;

/**
 * Interface that is used to render header elements (usually javascript and CSS
 * references).
 * 
 * Implementation of this interface is responsible for filtering duplicate
 * contributions (so that for example the same javascript is not loaded twice)
 * during the same request.
 * 
 * @author Matej Knopp
 */
public interface IHeaderResponse extends Serializable
{
	/**
	 * Writes a javascript reference, if the specified reference hasn't been
	 * rendered yet.
	 * 
	 * @param reference
	 *            resource reference pointing to the javascript resource
	 */
	public void renderJavascriptReference(ResourceReference reference);

	/**
	 * Writes a javascript reference, if the specified reference hasn't been
	 * rendered yet.
	 * 
	 * @param url
	 *            url of the the javascript resource
	 */
	public void renderJavascriptReference(String url);
	
	/**
	 * Renders javascript code to the response, if the javascript has not
	 * already been rendered.
	 * 
	 * the necessary surrounding <code>script</code> tags will be added to the
	 * output.
	 * 
	 * @param javascript
	 *            javacript content to be rendered.
	 * 
	 * @param 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 renderJavascript(CharSequence javascript, String id);

	/**
	 * Writes a CSS reference, if the specified reference hasn't been rendered
	 * yet.
	 * 
	 * @param reference
	 *            resource reference pointing to the CSS resource
	 */
	public void renderCSSReference(ResourceReference reference);
	
	/**
	 * Writes a CSS reference, if the specified reference hasn't been rendered
	 * yet.
	 * 
	 * @param url
	 *            url of the CSS resource
	 */
	public void renderCSSReference(String url);
	
	/**
	 * Writes a CSS reference, if the specified reference hasn't been rendered
	 * yet.
	 * 
	 * @param reference
	 *            resource reference pointing to the CSS resource
	 * @param media
	 * 			  the media type for this CSS ("print", "screen", etc.)
	 */
	public void renderCSSReference(ResourceReference reference, String media);
	
	/**
	 * Writes a CSS reference, if the specified reference hasn't been rendered
	 * yet.
	 * 
	 * @param url
	 *            url of the CSS resource
	 * @param media
	 * 			  the media type for this CSS ("print", "screen", etc.)
	 */
	public void renderCSSReference(String url, String media);

	/**
	 * Renders an arbitrary string to the header. The string is only rendered if
	 * the same string hasn't been rendered before.
	 * <p>
	 * Note: This method is kind of dangerous as users are able to write to the
	 * output whatever they like.
	 * 
	 * @param string
	 *            string to be rendered to head
	 */
	public void renderString(CharSequence string);

	/**
	 * 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).
	 * 
	 * @param object
	 *            object to be marked as rendered.
	 */
	public void markRendered(Object object);

	/**
	 * Returns whether the given object has been marked as rendered.
	 * <ul>
	 * <li>Methods <code>renderJavascriptReference</code> and
	 * <code>renderCSSReference</code> mark the specified
	 * {@link ResourceReference} as rendered.
	 * <li>Method <code>renderJavascript</code> marks List of two elements
	 * (first is javascript body CharSequence and second is id) as rendered.
	 * <li>Method <code>renderString</code> marks the whole string as
	 * rendered.
	 * <li>Method <code>markRendered</code> can be used to mark an arbitrary
	 * object as rendered
	 * </ul>
	 * 
	 * @param object
	 *            Object that is queried to be rendered
	 * @return Whether the object has been marked as rendered during the request
	 */
	public boolean wasRendered(Object object);

	/**
	 * Returns the response that can be used to write arbitrary text to the head
	 * section.
	 * <p>
	 * Note: This method is kind of dangerous as users are able to write to the
	 * output whatever they like.
	 * 
	 * @return Reponse
	 */
	public Response getResponse();
	
	/**
	 * Renders javascript that is executed right after the DOM is built, before external resources
	 * (e.g. images) are loaded.
	 * @param javascript
	 */
	public void renderOnDomReadyJavascript(String javascript);
	
	/**
	 * Renders javascript that is executed after the entire page is loaded.
	 * @param javascript
	 */
	public void renderOnLoadJavascript(String javascript);
}

@@ -829,38 +829,8 @@
 l;%0A%0A
-import java.io.Serializable;%0A%0A
 impo
@@ -858,16 +858,16 @@
 erence;%0A
+
 import w
@@ -1236,29 +1236,8 @@
 onse
- extends Serializable
 %0A%7B%0A%09
@@ -1719,34 +1719,33 @@
 ce(String url);%0A
-%09
 %0A
+
 %09/**%0A%09 * Renders
@@ -2530,18 +2530,17 @@
 rence);%0A
-%09
 %0A
+
 %09/**%0A%09 *
@@ -2730,18 +2730,17 @@
 g url);%0A
-%09
 %0A
+
 %09/**%0A%09 *
@@ -2923,35 +2923,41 @@
 param media%0A%09 * 
-%09%09%09
+         
   the media type
@@ -3077,18 +3077,17 @@
 media);%0A
-%09
 %0A
+
 %09/**%0A%09 *
@@ -3252,11 +3252,17 @@
 %09 * 
-%09%09%09
+         
   th
@@ -5212,18 +5212,17 @@
 onse();%0A
-%09
 %0A
+
 %09/**%0A%09 *
@@ -5294,16 +5294,20 @@
 , before
+%0A%09 *
  externa
@@ -5317,20 +5317,16 @@
 esources
-%0A%09 *
  (e.g. i
@@ -5336,32 +5336,37 @@
 es) are loaded.%0A
+%09 * %0A
 %09 * @param javas
@@ -5440,15 +5440,14 @@
 t);%0A
-%09
 %0A
+
 %09/**%0A
-
 %09 * 
@@ -5511,24 +5511,29 @@
  is loaded.%0A
+%09 * %0A
 %09 * @param j

should not be serializable