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.ajax; 018 019import java.util.List; 020 021import org.apache.wicket.Application; 022import org.apache.wicket.markup.head.HeaderItem; 023import org.apache.wicket.markup.head.JavaScriptHeaderItem; 024import org.apache.wicket.request.resource.JavaScriptResourceReference; 025import org.apache.wicket.request.resource.ResourceReference; 026import org.apache.wicket.resource.JQueryResourceReference; 027 028/** 029 * @author hoeve 030 */ 031public class WicketAjaxJQueryResourceReference extends JavaScriptResourceReference 032{ 033 private static final long serialVersionUID = -2918665261694523156L; 034 035 private static final WicketAjaxJQueryResourceReference INSTANCE = new WicketAjaxJQueryResourceReference(); 036 037 /** 038 * @return the singleton INSTANCE 039 */ 040 public static WicketAjaxJQueryResourceReference get() 041 { 042 return INSTANCE; 043 } 044 045 private WicketAjaxJQueryResourceReference() 046 { 047 super(AbstractDefaultAjaxBehavior.class, "res/js/wicket-ajax-jquery.js"); 048 } 049 050 @Override 051 public List<HeaderItem> getDependencies() 052 { 053 final ResourceReference jqueryReference; 054 if (Application.exists()) 055 { 056 jqueryReference = Application.get().getJavaScriptLibrarySettings().getJQueryReference(); 057 } 058 else 059 { 060 jqueryReference = JQueryResourceReference.getV3(); 061 } 062 List<HeaderItem> dependencies = super.getDependencies(); 063 dependencies.add(JavaScriptHeaderItem.forReference(jqueryReference)); 064 return dependencies; 065 } 066}