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


fiftyfive.wicket.js
Class MergedJavaScriptBuilder

java.lang.Object
  extended by fiftyfive.wicket.resource.MergedResourceBuilder
      extended by fiftyfive.wicket.js.MergedJavaScriptBuilder

public class MergedJavaScriptBuilder
extends MergedResourceBuilder

Instructs Wicket to merge a list of JavaScript resources into a single file when the application is in deployment mode. Consider using this in your application as a performance optimization.

Example usage:

 public class MyApplication extends WebApplication
 {
     @Override
     protected void init()
     {
         super.init();
 
         new MergedJavaScriptBuilder()
             .setPath("/scripts/all.js")
             .addWicketAjaxLibraries()
             .addJQueryUI()
             .addLibrary("jquery.scrollTo")
             .addLibrary("jquery.55_utils")
             .addLibrary("55_utils")
             .addLibrary("strftime")
             .build(this);
 
         // The return value from build() can be used on your base page to
         // inject all these JavaScript resources in one shot, if desired.
     }
 }

Since:
2.0

Constructor Summary
MergedJavaScriptBuilder()
          Creates an empty builder object.
 
Method Summary
 MergedJavaScriptBuilder addAssociatedScript(Class<?> cls)
          Adds a JavaScript resource of the same name and location of the given class, except with the ".js" extension.
 MergedJavaScriptBuilder addJQueryUI()
          Adds jQuery and jQuery UI to the list of merged resources.
 MergedJavaScriptBuilder addLibrary(String libraryName)
          Adds a JavaScript library to the list of merged resources.
 MergedJavaScriptBuilder addScript(Class<?> scope, String path)
          Adds a JavaScript file to the list of merged resources.
 MergedJavaScriptBuilder addScript(ResourceReference ref)
          Adds a JavaScript resource to the list of merged resources.
 MergedJavaScriptBuilder addWicketAjaxLibraries()
          Adds Wicket's wicket-event.js and wicket-ajax.js files to the list of merged resources.
 AbstractHeaderContributor build(WebApplication app)
          Constructs a special merged resource using the path and resources options specified in this builder, and mounts the result in the application.
protected  IHeaderContributor newContributor(ResourceReference ref)
          Constructs a header contributor for the given resource.
 MergedJavaScriptBuilder setPath(String path)
          Sets the path at which the merged resources will be mounted.
 
Methods inherited from class fiftyfive.wicket.resource.MergedResourceBuilder
add
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergedJavaScriptBuilder

public MergedJavaScriptBuilder()
Creates an empty builder object. See the class documentation for example usage.

Method Detail

setPath

public MergedJavaScriptBuilder setPath(String path)
Description copied from class: MergedResourceBuilder
Sets the path at which the merged resources will be mounted. For example, "/styles/all.css".

Overrides:
setPath in class MergedResourceBuilder

addScript

public MergedJavaScriptBuilder addScript(Class<?> scope,
                                         String path)
Adds a JavaScript file to the list of merged resources. The dependencies of the script, if declared using JavaScriptDependencySettings

addScript

public MergedJavaScriptBuilder addScript(ResourceReference ref)
Adds a JavaScript resource to the list of merged resources. The dependencies of the script, if declared using Sprockets syntax within the JS file, will also be added automatically.

See Also:
JavaScriptDependencySettings

addAssociatedScript

public MergedJavaScriptBuilder addAssociatedScript(Class<?> cls)
Adds a JavaScript resource of the same name and location of the given class, except with the ".js" extension. These two statements are equivalent:
 addAssociatedScript(MyPanel.class);
 addScript(MyPanel.class, "MyPanel.js");

The dependencies of the script, if declared using Sprockets syntax within the JS file, will also be added automatically.

See Also:
JavaScriptDependencySettings

addJQueryUI

public MergedJavaScriptBuilder addJQueryUI()
Adds jQuery and jQuery UI to the list of merged resources.

See Also:
JavaScriptDependencySettings

addWicketAjaxLibraries

public MergedJavaScriptBuilder addWicketAjaxLibraries()
Adds Wicket's wicket-event.js and wicket-ajax.js files to the list of merged resources.

See Also:
JavaScriptDependencySettings

addLibrary

public MergedJavaScriptBuilder addLibrary(String libraryName)
Adds a JavaScript library to the list of merged resources. The dependencies of the script, if declared using Sprockets syntax within the JS file, will also be added automatically.

See Also:
JavaScriptDependencySettings

build

public AbstractHeaderContributor build(WebApplication app)
Description copied from class: MergedResourceBuilder
Constructs a special merged resource using the path and resources options specified in this builder, and mounts the result in the application. The resources will remain separate in development mode, but will be merged together into a single file in deployment mode.

This method must be called after all of the options have been set.

If desired, the HeaderContributor returned by this method can be used to contribute the merged resource to the pages or components of your choice.

Overrides:
build in class MergedResourceBuilder
Returns:
A HeaderContributor that will contribute all the JavaScript or CSS resources that were specified in this builder.

newContributor

protected IHeaderContributor newContributor(ResourceReference ref)
Description copied from class: MergedResourceBuilder
Constructs a header contributor for the given resource. Subclasses should implement the appropriate CSS or JS contributor.

Specified by:
newContributor in class MergedResourceBuilder


Copyright © 2011 55 Minutes. All Rights Reserved.