001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.settings;
018
019import org.apache.wicket.ajax.WicketAjaxJQueryResourceReference;
020import org.apache.wicket.request.resource.ResourceReference;
021import org.apache.wicket.resource.JQueryResourceReference;
022import org.apache.wicket.util.lang.Args;
023
024/**
025 * Class for settings related to the JavaScript libraries that come with and are used by Wicket.
026 * <p>
027 * With these settings the user application can replace the JavaScript libraries used for Wicket's
028 * event and Ajax functionality. By default Wicket uses {@linkplain JQueryResourceReference JQuery}
029 * as a backing library but via this interface the application can replace the implementations of
030 * wicket-event.js, wicket-ajax.js and wicket-ajax-debug.js to use implementations on other
031 * libraries, such as YUI or DOJO. The resource reference implementations need to specify the
032 * {@linkplain ResourceReference#getDependencies() dependency} on the backing library, if needed.
033 *
034 * @since 6.0
035 */
036public class JavaScriptLibrarySettings
037{
038        private ResourceReference jQueryReference = JQueryResourceReference.getV3();
039
040        private ResourceReference wicketAjaxReference = WicketAjaxJQueryResourceReference.get();
041
042        /**
043         * @return the reference to the JQuery JavaScript library used as backing library for
044         *         wicket-event and wicket-ajax
045         */
046        public ResourceReference getJQueryReference()
047        {
048                return jQueryReference;
049        }
050
051        /**
052         * @param jQueryReference
053         *            a reference to the JQuery JavaScript library used as backing library for
054         *            wicket-event and wicket-ajax
055         * @return {@code this} object for chaining
056         */
057        public JavaScriptLibrarySettings setJQueryReference(ResourceReference jQueryReference)
058        {
059                this.jQueryReference = Args.notNull(jQueryReference, "jQueryReference");
060                return this;
061        }
062
063        /**
064         * @return the reference to the implementation of wicket-ajax.js
065         */
066        public ResourceReference getWicketAjaxReference()
067        {
068                return wicketAjaxReference;
069        }
070
071        /**
072         * @param wicketAjaxReference
073         *            a reference to the implementation of wicket-ajax.js
074         * @return {@code this} object for chaining
075         */
076        public JavaScriptLibrarySettings setWicketAjaxReference(ResourceReference wicketAjaxReference)
077        {
078                this.wicketAjaxReference = Args.notNull(wicketAjaxReference, "wicketAjaxReference");
079                return this;
080        }
081}