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


fiftyfive.wicket.js
Class DomReadyScript

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

public class DomReadyScript
extends AbstractJavaScriptContribution

Renders a script tag in the <head> that executes specified JavaScript code on DOM ready. The code will run when the page loads, and also every time the component to which this behavior is attached is repainted via Wicket ajax.

This behavior will cause jQuery to be added to the <head> if it is not there already. Your script can rely on the jQuery object being available.

The script will not be scanned for dependencies declared using the sprocket syntax. This behavior is intended for short one-liner initialization scripts.

Trivial example:

 public MyPanel(String id)
 {
     super(id);
     add(new DomReadyScript("alert('page ready!')"));
 }

Since:
2.0
See Also:
Serialized Form

Constructor Summary
DomReadyScript(IModel<String> readyScript)
          Creates an IBehavior object that will add the given javascript string to the <head> for execution on DOM ready.
DomReadyScript(String readyScript)
          Creates an IBehavior object that will add the given javascript string to the <head> for execution on DOM ready.
 
Method Summary
 void detach(Component component)
          Detaches the javascript string model that was provided in the constructor.
 void renderHead(IHeaderResponse response)
          Renders the DOM-ready script in the <head>.
 
Methods inherited from class fiftyfive.wicket.js.AbstractJavaScriptContribution
renderDependencies, renderDomReady
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, bind, cleanup, detachModel, exception, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onException, onRendered, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomReadyScript

public DomReadyScript(String readyScript)
Creates an IBehavior object that will add the given javascript string to the <head> for execution on DOM ready.


DomReadyScript

public DomReadyScript(IModel<String> readyScript)
Creates an IBehavior object that will add the given javascript string to the <head> for execution on DOM ready.

Method Detail

detach

public void detach(Component component)
Detaches the javascript string model that was provided in the constructor.

Specified by:
detach in interface IBehavior
Overrides:
detach in class AbstractBehavior

renderHead

public void renderHead(IHeaderResponse response)
Renders the DOM-ready script in 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() { ... });

Specified by:
renderHead in interface IHeaderContributor
Overrides:
renderHead in class AbstractBehavior


Copyright © 2011 55 Minutes. All Rights Reserved.