This documentation is for an old version of fiftyfive-wicket (2.0.9).


fiftyfive.wicket.js.locator
Class DefaultJavaScriptDependencyLocator

java.lang.Object
  extended by fiftyfive.wicket.js.locator.DefaultJavaScriptDependencyLocator
All Implemented Interfaces:
JavaScriptDependencyLocator

public class DefaultJavaScriptDependencyLocator
extends Object
implements JavaScriptDependencyLocator

Default implementation of JavaScriptDependencyLocator. Uses the Wicket application's IResourceStreamLocator to load JavaScript files, and our SprocketDependencyCollector to parse them for dependencies. A ConcurrentHashMap is used as a simple in-memory cache for the dependency trees that are discovered.

Since:
2.0

Constructor Summary
DefaultJavaScriptDependencyLocator()
           
 
Method Summary
 void findAssociatedScripts(Class<?> cls, DependencyCollection scripts)
          Locates a JavaScript file in the classpath with the same name and location as a given class, and adds it, along with of its dependencies, to the specified DependencyCollection.
 void findLibraryScripts(String libraryName, DependencyCollection scripts)
          Locates the JavaScript library with the given name and adds it, along with all of its dependencies, to the specified DependencyCollection.
 void findResourceScripts(Class<?> cls, String fileName, DependencyCollection scripts)
          Locates a JavaScript file in the classpath relative to a class, and adds it, along with of its dependencies, to the specified DependencyCollection.
protected  ResourceReference getJQueryUITheme()
          Returns a reference to the CSS file that should be used to style jQuery UI widgets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJavaScriptDependencyLocator

public DefaultJavaScriptDependencyLocator()
Method Detail

findLibraryScripts

public void findLibraryScripts(String libraryName,
                               DependencyCollection scripts)
Description copied from interface: JavaScriptDependencyLocator
Locates the JavaScript library with the given name and adds it, along with all of its dependencies, to the specified DependencyCollection. This will search the library paths that have been configured for the application.

Specified by:
findLibraryScripts in interface JavaScriptDependencyLocator
Parameters:
libraryName - Name of the JavaScript library, like "jquery-ui". The name should not include the ".js" extension.
scripts - The library and all of its dependencies will be added to this collection in the order that they should appear in the HTML <head>.

findResourceScripts

public void findResourceScripts(Class<?> cls,
                                String fileName,
                                DependencyCollection scripts)
Description copied from interface: JavaScriptDependencyLocator
Locates a JavaScript file in the classpath relative to a class, and adds it, along with of its dependencies, to the specified DependencyCollection.

Specified by:
findResourceScripts in interface JavaScriptDependencyLocator
Parameters:
cls - The JavaScript file will be located relative to this class.
fileName - Name of the JavaScript file as it appears in the classpath relative to the specified class, without the ".js" extension.
scripts - The script and all of its dependencies will be added to this collection in the order that they should appear in the HTML <head>.

findAssociatedScripts

public void findAssociatedScripts(Class<?> cls,
                                  DependencyCollection scripts)
Description copied from interface: JavaScriptDependencyLocator
Locates a JavaScript file in the classpath with the same name and location as a given class, and adds it, along with of its dependencies, to the specified DependencyCollection. If the given class has no JavaScript file, its superclass is searched, and so on up the class hierarchy.

Specified by:
findAssociatedScripts in interface JavaScriptDependencyLocator
Parameters:
cls - Specifies the name and location of the JavaScript file. For example, if the class is MyPanel.class, the JavaScript file that will be located will be MyPanel.js in the same classpath location. Superclasses will also be searched until a JS file can be found.
scripts - The script and all of its dependencies will be added to this collection in the order that they should appear in the HTML <head>.

getJQueryUITheme

protected ResourceReference getJQueryUITheme()
Returns a reference to the CSS file that should be used to style jQuery UI widgets. The default implementation simply delegates to JavaScriptDependencySettings.getJQueryUICSSResource(). This means that one style is used for the entire application. If you want something more advanced, for example to choose a theme based on user preferences or a session value, override this method for your custom logic.



Copyright © 2011 55 Minutes. All Rights Reserved.