


Class _ResourceReference_ allows to specify the resources it depends on overriding method _getDependencies()_. The method returns a list of _HeaderItemS_ that must be rendered before the resource referenced by _ResourceReference_ can be used. This can be really helpful when our resources are JavaScript or CSS libraries that in turn depend on other libraries.

For example we can use this method to ensure that a custom reference to JQueryUI library will find JQuery already loaded in the page: 

[source,java]
----
Url jqueryuiUrl = Url.parse("https://ajax.googleapis.com/ajax/libs/jqueryui/" +
                                                                 "1.10.2/jquery-ui.min.js");

UrlResourceReference jqueryuiRef = new UrlResourceReference(jqueryuiUrl){
	@Override
	public List<HeaderItem> getDependencies() {
		Application application = Application.get();
		ResourceReference jqueryRef = application.getJavaScriptLibrarySettings(). 
                                             getJQueryReference();
				
		return Arrays.asList(JavaScriptHeaderItem.forReference(jqueryRef));
	}
};
----

Please note that in the code above we have built a resource reference using a URL to the desired library instead of a package resource holding the physical file.

NOTE: Wicket already provides base class _org.apache.wicket.resource.JQueryPluginResourceReference_ for those JavaScript resources that depend on JQuery. This class uses the JQuery version bundled with Wicket.

NOTE: The same method _getDependencies()_ is defined also for class _HeaderItem_.

