All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wicketstuff.select2.Select2ResourcesBehavior Maven / Gradle / Ivy

There is a newer version: 10.1.1
Show newest version
/*
 * Copyright 2012 Igor Vaynberg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
 * the License. You may obtain a copy of the License in the LICENSE file, or 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.wicketstuff.select2;

import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;

/**
 * Adds various resources needed by Select2 such as JavaScript and CSS. Which resources are added is
 * controlled by the {@link ApplicationSettings} object. Minified versions of JavaScript resources
 * will be used when the application is configured in deployment mode.
 * 
 * @author igor
 * 
 */
public class Select2ResourcesBehavior extends Behavior
{
	private static final long serialVersionUID = 1L;

	@Override
	public void renderHead(Component component, IHeaderResponse response)
	{

		final ApplicationSettings settings = ApplicationSettings.get();

		// Include Wicket's provided jQuery reference
		response.render(JavaScriptHeaderItem.forReference(Application.get()
			.getJavaScriptLibrarySettings()
			.getJQueryReference()));

		if (settings.isIncludeJavascriptFull())
		{
			response.render(JavaScriptHeaderItem.forReference(settings.getJavaScriptReferenceFull()));
		}

		if (settings.isIncludeJavascript())
		{
			response.render(JavaScriptHeaderItem.forReference(settings.getJavaScriptReference()));
		}

		if (settings.isIncludeCss())
		{
			response.render(CssHeaderItem.forReference(settings.getCssReference()));
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy