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


fiftyfive.wicket.js
Class JavaScriptDependencySettings

java.lang.Object
  extended by fiftyfive.wicket.js.JavaScriptDependencySettings

public class JavaScriptDependencySettings
extends Object

Settings that affect how JavaScript dependencies are located. To obtain an instance, use the static get() method.

Most applications using out-of-the-box JavaScript widgets will be served well by the default settings. However there are three important scenarios to consider:

  1. If your application already has a mechanism for including jQuery and/or jQuery UI in the <head> (e.g. via your base page), then you should take care that fiftyfive-wicket-js is not including its own copies of these libraries. In this scenario, call setJQueryResource() and setJQueryUIResource() with references to the files that your application is already using (or null, if you don't want fiftyfive-wicket-js to manage these resources at all).
  2. If you have your own library of custom JavaScript files, consider placing those files inside your classpath, and then use addLibraryPath() to make fiftyfive-wicket-js aware of them. Then you can use the angle-bracket dependency syntax or the single argument constructor for JavaScriptDependency, and those files will be found automatically.
  3. If you'd like to change the jQuery UI CSS theme, call setJQueryUICSSResource() with a reference to the desired CSS file, or null if you don't want fiftyfive-wicket-js to manage this for you.

Since:
2.0

Constructor Summary
protected JavaScriptDependencySettings(Application app)
          Constructs a settings object for the given application with a reasonable set of defaults.
 
Method Summary
 JavaScriptDependencySettings addLibraryPath(Class<?> cls, String path)
          Adds a classpath location to be used for locating JavaScript libraries.
static JavaScriptDependencySettings get()
          Returns the JavaScriptDependencySettings associated with the current Wicket Application, creating a new default settings object if one does not yet exist.
 String getEncoding()
          Returns the character encoding that will be used when parsing JavaScript files.
 ResourceReference getJQueryResource()
          Returns the ResourceReference for the jQuery JavaScript file.
 ResourceReference getJQueryUICSSResource()
          Returns the ResourceReference for the jQuery UI CSS theme file.
 ResourceReference getJQueryUIResource()
          Returns the ResourceReference for the jQuery UI JavaScript file.
 List<SearchLocation> getLibraryPaths()
          Returns the list of classpath locations that will be used to find JavaScript libraries.
 JavaScriptDependencyLocator getLocator()
          Returns the JavaScriptDependencyLocator for this application.
 Duration getTraversalCacheDuration()
          Returns the duration that JavaScript dependency traversal results (i.e.
 JavaScriptDependencySettings setEncoding(String encoding)
          Sets the character encoding that will be used when parsing JavaScript files.
 JavaScriptDependencySettings setJQueryResource(ResourceReference r)
          Sets the ResourceReference of the jQuery JavaScript file that should be used whenever the dependency locator determines that jQuery is needed.
 JavaScriptDependencySettings setJQueryUICSSResource(ResourceReference r)
          Sets the ResourceReference of the jQuery UI CSS theme file that should be used whenever the dependency locator determines that jQuery UI is needed.
 JavaScriptDependencySettings setJQueryUIResource(ResourceReference r)
          Sets the ResourceReference of the jQuery UI JavaScript file that should be used whenever the dependency locator determines that jQuery UI is needed.
 JavaScriptDependencySettings setLocator(JavaScriptDependencyLocator loc)
          Sets the JavaScriptDependencyLocator that should be used for this application.
 JavaScriptDependencySettings setTraversalCacheDuration(Duration d)
          Sets the duration that JavaScript dependency traversal results (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptDependencySettings

protected JavaScriptDependencySettings(Application app)
Constructs a settings object for the given application with a reasonable set of defaults.

Method Detail

get

public static JavaScriptDependencySettings get()
Returns the JavaScriptDependencySettings associated with the current Wicket Application, creating a new default settings object if one does not yet exist. This method can only be called within a Wicket thread.


getLocator

public JavaScriptDependencyLocator getLocator()
Returns the JavaScriptDependencyLocator for this application.


setLocator

public JavaScriptDependencySettings setLocator(JavaScriptDependencyLocator loc)
Sets the JavaScriptDependencyLocator that should be used for this application. By default this is DefaultJavaScriptDependencyLocator.

Returns:
this to allow chaining

getLibraryPaths

public List<SearchLocation> getLibraryPaths()
Returns the list of classpath locations that will be used to find JavaScript libraries.


addLibraryPath

public JavaScriptDependencySettings addLibraryPath(Class<?> cls,
                                                   String path)
Adds a classpath location to be used for locating JavaScript libraries. A default list of locations from the fiftyfive-wicket-js JAR contains jQuery, jQuery UI, cookies, fiftyfive-utils, jquery-scrollto and strftime. Call this method if you wish to add more libraries to this list, or if you want your versions of the previously mentioned libraries to take precedence. The paths that you add will be consulted before the defaults.

Library paths are searched whenever you use the angle-bracket syntax for JavaScript dependencies, like this:

 //= require <libraryname>

Or when you use JavaScriptDependency.JavaScriptDependency(String) or MergedJavaScriptBuilder.addLibrary(String).

Returns:
this to allow chaining

getJQueryResource

public ResourceReference getJQueryResource()
Returns the ResourceReference for the jQuery JavaScript file.


setJQueryResource

public JavaScriptDependencySettings setJQueryResource(ResourceReference r)
Sets the ResourceReference of the jQuery JavaScript file that should be used whenever the dependency locator determines that jQuery is needed. Pass null if you do not want the framework to include jQuery automatically. By default this refers to a copy of jQuery bundled in the fiftyfive-wicket-js JAR.

Returns:
this to allow chaining

getJQueryUIResource

public ResourceReference getJQueryUIResource()
Returns the ResourceReference for the jQuery UI JavaScript file.


setJQueryUIResource

public JavaScriptDependencySettings setJQueryUIResource(ResourceReference r)
Sets the ResourceReference of the jQuery UI JavaScript file that should be used whenever the dependency locator determines that jQuery UI is needed. Pass null if you do not want the framework to include jQuery UI automatically. By default this refers to a copy of jQuery UI bundled in the fiftyfive-wicket-js JAR.

Returns:
this to allow chaining

getJQueryUICSSResource

public ResourceReference getJQueryUICSSResource()
Returns the ResourceReference for the jQuery UI CSS theme file.


setJQueryUICSSResource

public JavaScriptDependencySettings setJQueryUICSSResource(ResourceReference r)
Sets the ResourceReference of the jQuery UI CSS theme file that should be used whenever the dependency locator determines that jQuery UI is needed. Pass null if you do not want the framework to include jQuery UI CSS automatically. By default this refers to a copy of jQuery UI "redmond" theme bundled in the fiftyfive-wicket-js JAR.

Returns:
this to allow chaining

getTraversalCacheDuration

public Duration getTraversalCacheDuration()
Returns the duration that JavaScript dependency traversal results (i.e. the tree of dependencies as determined by parsing sprockets directives) are allowed to be stored in cache.


setTraversalCacheDuration

public JavaScriptDependencySettings setTraversalCacheDuration(Duration d)
Sets the duration that JavaScript dependency traversal results (i.e. the tree of dependencies as determined by parsing sprockets directives) are allowed to be stored in cache.

If this is set to null (the default), at runtime this will be interpreted as a value of zero (cache disabled) if the application is in development mode, and will be interpreted as the maximum duration (effectively indefinite) if the application is in deployment mode.

Returns:
this to allow chaining

getEncoding

public String getEncoding()
Returns the character encoding that will be used when parsing JavaScript files.


setEncoding

public JavaScriptDependencySettings setEncoding(String encoding)
Sets the character encoding that will be used when parsing JavaScript files. If this is set to null (the default), then Wicket's markup encoding setting will be used.

Returns:
this to allow chaining
See Also:
IMarkupSettings.getDefaultMarkupEncoding()


Copyright © 2011 55 Minutes. All Rights Reserved.