Class AbstractJQueryBehavior<ConfigType>

  extended by org.wamblee.wicket.behavior.CompositeBehavior
      extended by org.wamblee.wicket.jquery.AbstractJQueryBehavior<ConfigType>
All Implemented Interfaces:, org.apache.wicket.behavior.IBehavior, org.apache.wicket.IClusterable, org.apache.wicket.markup.html.IHeaderContributor
Direct Known Subclasses:
AbstractTooltipBehavior, PreselectionBehavior

public class AbstractJQueryBehavior<ConfigType>
extends CompositeBehavior

Abstract JQuery hehavior class that makes it easy to write jQuery behaviors:

The ready function will be invoked as part of a ready handler and will invoke a function with two arguments. The first is the selector of the component and the second is a configuration object. In case the behavior is attached to a component, a selector is used based on the unique markup id. When used on a page, the selector matches with the "body" of the page.

The second parameter is obtained through a call to getConfigurationJavascript().

Erik Brakkee
See Also:
Serialized Form

Constructor Summary
AbstractJQueryBehavior(java.lang.String aFunction, org.apache.wicket.behavior.IBehavior... aBehaviors)
          Constructs the behavior.
Method Summary
 void bind(org.apache.wicket.Component aComponent)
protected  java.lang.String getConfigurationJavascript()
          Returns a javascript object that is passed as second argument to the ready function.
protected  ConfigType getConfigurationObject()
          Gets the configuration object to use.
protected  flexjson.JSONSerializer getCustomSerializer()
          Returns the serializer to use.
protected  boolean isPageAllowed()
          Determines whether the behavior is allowed to be attached toa page.
 void renderHead(org.apache.wicket.markup.html.IHeaderResponse aResponse)
Methods inherited from class org.wamblee.wicket.behavior.CompositeBehavior
add, afterRender, beforeRender, detach, exception, getStatelessHint, isEnabled, isTemporary, onComponentTag
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public AbstractJQueryBehavior(java.lang.String aFunction,
                              org.apache.wicket.behavior.IBehavior... aBehaviors)
Constructs the behavior.

aFunction - Function to be invoked from the ready handler. This function is invoked with a CSS selector that identifies the component.
aBehaviors - Behaviors to add in addition to the basic JQuery stuff.
Method Detail


protected boolean isPageAllowed()
Determines whether the behavior is allowed to be attached toa page.



public void bind(org.apache.wicket.Component aComponent)
Specified by:
bind in interface org.apache.wicket.behavior.IBehavior
bind in class CompositeBehavior


public void renderHead(org.apache.wicket.markup.html.IHeaderResponse aResponse)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
renderHead in class CompositeBehavior


protected java.lang.String getConfigurationJavascript()
Returns a javascript object that is passed as second argument to the ready function. This method uses getConfigurationObject() to obtain the configuration object to use which is then serialized to javascript using JSONSerializer. Subclasses can override the default JSONSerializer by implementing getCustomSerializer().

Subclasses should override this method to perform custom serialization.

Configuration object in javascript.


protected flexjson.JSONSerializer getCustomSerializer()
Returns the serializer to use. Implementations can override this method to perform custom initialization of the serializer knowing the type of configuration object to use.

Custom serializer to use.


protected ConfigType getConfigurationObject()
Gets the configuration object to use. This is transformed to JSON using the serializer.

Configuration object.

Copyright © 2022. All Rights Reserved.