Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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 org.apache.wicket.behavior;
 
A AbstractHeaderContributor behavior that is specialized on package resources. If you use this class, you have to pre-register the resources you want to contribute. A shortcut for common cases is to call forCss(java.lang.Class,java.lang.String) to contribute a package css file or forJavaScript(java.lang.Class,java.lang.String) to contribute a packaged javascript file. For instance:
 add(HeaderContributor.forCss(MyPanel.class, "mystyle.css"));
 

Author(s):
Eelco Hillenius
Matej Knopp
 
 {
 	private static final long serialVersionUID = 1L;

Returns a new instance of HeaderContributor with a header contributor that references a CSS file that lives in a package.

Parameters:
scope The scope of the package resource (typically the class of the caller, or a class that lives in the package where the resource lives).
path The path
Returns:
the new header contributor instance
 
 	public static final HeaderContributor forCss(final Class scopefinal String path)
 	{
 		{
 			private static final long serialVersionUID = 1L;
 
 			public void renderHead(IHeaderResponse response)
 			{
 				response.renderCSSReference(new CompressedResourceReference(scopepath));
 			}
 		});
 	}

Returns a new instance of HeaderContributor with a header contributor that references a CSS file that lives in a package.

Parameters:
scope The scope of the package resource (typically the class of the caller, or a class that lives in the package where the resource lives).
path The path
media The media type for this CSS ("print", "screen", etc.)
Returns:
the new header contributor instance
 
 	public static final HeaderContributor forCss(final Class scopefinal String path,
 		final String media)
 	{
 		{
 			private static final long serialVersionUID = 1L;
 
 			public void renderHead(IHeaderResponse response)
 			{
 				response.renderCSSReference(new CompressedResourceReference(scopepath), media);
 			}
 		});
 	}

Returns a new instance of HeaderContributor with a header contributor that references a CSS file that lives in a package.

Parameters:
reference
Returns:
the new header contributor instance
	public static final HeaderContributor forCss(final ResourceReference reference)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
				response.renderCSSReference(reference);
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor that references a CSS file that lives in a package.

Parameters:
reference
media The media type for this CSS ("print", "screen", etc.)
Returns:
the new header contributor instance
	public static final HeaderContributor forCss(final ResourceReference reference,
		final String media)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
				response.renderCSSReference(referencemedia);
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor referencing a CSS file using one of the following schemes:
  • Starts with http:// or https:// for an external reference.
  • Starts with "/" for an absolute reference that Wicket will not rewrite.
  • Starts with anything else, which Wicket will automatically prepend to make relative to the context root of your web-app.

Parameters:
location The location of the css file.
Returns:
the new header contributor instance
	public static final HeaderContributor forCss(final String location)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor referencing a CSS file using one of the following schemes:
  • Starts with http:// or https:// for an external reference.
  • Starts with "/" for an absolute reference that Wicket will not rewrite.
  • Starts with anything else, which Wicket will automatically prepend to make relative to the context root of your web-app.

Parameters:
location The location of the css.
media The media type for this CSS ("print", "screen", etc.)
Returns:
the new header contributor instance
	public static final HeaderContributor forCss(final String locationfinal String media)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
				response.renderCSSReference(returnRelativePath(location), media);
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor that references a java script file that lives in a package.

Parameters:
scope The scope of the package resource (typically the class of the caller, or a class that lives in the package where the resource lives).
path The path
Returns:
the new header contributor instance
	public static final HeaderContributor forJavaScript(final Class scopefinal String path)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor that references a java script file that lives in a package.

Parameters:
reference
Returns:
the new header contributor instance
	public static final HeaderContributor forJavaScript(final ResourceReference reference)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
				response.renderJavascriptReference(reference);
			}
		});
	}

Returns a new instance of HeaderContributor with a header contributor referencing a java script file using one of the following schemes:
  • Starts with http:// or https:// for an external reference.
  • Starts with "/" for an absolute reference that Wicket will not rewrite.
  • Starts with anything else, which Wicket will automatically prepend to make relative to the context root of your web-app.

Parameters:
location The location of the java script file.
Returns:
the new header contributor instance
	public static final HeaderContributor forJavaScript(final String location)
	{
		{
			private static final long serialVersionUID = 1L;
			public void renderHead(IHeaderResponse response)
			{
			}
		});
	}
	// Adds ../ links to make the location relative to the root of the webapp,
	// provided it's not a fully-qualified URL.
	private static final String returnRelativePath(String location)
	{
		// WICKET-59 allow external URLs, WICKET-612 allow absolute URLs.
		if (location.startsWith("http://") || location.startsWith("https://") ||
			location.startsWith("/"))
		{
			return location;
		}
		else
		{
			return RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + location;
		}
	}

Resource reference to contribute.
Construct.

Parameters:
headerContributor the header contributor
	public HeaderContributor(IHeaderContributor headerContributor)
	{
		if (headerContributor == null)
		{
			throw new IllegalArgumentException("header contributor may not be null");
		}
		this. = headerContributor;
	}

	{
	}
New to GrepCode? Check out our FAQ X