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


fiftyfive.wicket.js
Class AbstractJavaScriptContribution

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by fiftyfive.wicket.js.AbstractJavaScriptContribution
All Implemented Interfaces:
Serializable, IBehavior, IComponentConfigurationBehavior, IClusterable, IHeaderContributor
Direct Known Subclasses:
DomReadyScript, DomReadyTemplate, JavaScriptDependency

public abstract class AbstractJavaScriptContribution
extends AbstractBehavior

Base class for fiftyfive-wicket-js JavaScript <head> behaviors. Provides methods for rendering dependencies as script src tags, and DOM-ready scripts as the appropriate wicket-event.js or jQuery DOM-ready declaration.

You will most likely never need to use this class or subclass it directly.

Since:
2.0
See Also:
Serialized Form

Constructor Summary
AbstractJavaScriptContribution()
           
 
Method Summary
protected  void renderDependencies(IHeaderResponse response, DependencyCollection dependencies, ResourceReference exclude)
          Renders a collection of JavaScript dependencies to the <head> as script src tags.
protected  void renderDomReady(IHeaderResponse response, String script)
          Injects the given JavaScript string into a DOM-ready code block within the <head>.
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, bind, cleanup, detach, detachModel, exception, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onException, onRendered, rendered, renderHead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJavaScriptContribution

public AbstractJavaScriptContribution()
Method Detail

renderDependencies

protected void renderDependencies(IHeaderResponse response,
                                  DependencyCollection dependencies,
                                  ResourceReference exclude)
Renders a collection of JavaScript dependencies to the <head> as script src tags. If the dependencies include a CSS resource, that is rendered as well, using an appropriate <link> tag.

Parameters:
response - The header object provided by Wicket, into which the <script> and <link> tags will be written.
dependencies - The dependencies to render. May be empty.
exclude - If not null, this particular dependency will be skipped and not rendered when traversing the dependency collection.

renderDomReady

protected void renderDomReady(IHeaderResponse response,
                              String script)
Injects the given JavaScript string into a DOM-ready code block within the <head>.

If we are within an ajax request, use Wicket's standard renderOnDomReadyJavascript() method to add javascript to the <head>. During non-ajax requests, instead add the following jQuery snippet to execute the javacript on DOM ready: jQuery(function() { ... });

In either case, a script src tag for jQuery will be added to the <head> if it was not there already.



Copyright © 2011 55 Minutes. All Rights Reserved.