Class JQueryBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- com.googlecode.wicket.jquery.core.JQueryAbstractBehavior
-
- com.googlecode.wicket.jquery.core.JQueryBehavior
-
- All Implemented Interfaces:
Serializable,IComponentAwareEventSink,IComponentAwareHeaderContributor,IClusterable
public class JQueryBehavior extends JQueryAbstractBehavior
Provides a default implementation ofJQueryAbstractBehavior.- Since:
- 1.0
- Author:
- Sebastien Briquet - sebfz1
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JQueryBehavior(String selector)ConstructorJQueryBehavior(String selector, String method)ConstructorJQueryBehavior(String selector, String method, Options options)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String$()Gets the jQuery statement.String$(Options options)Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).String$(Object... options)Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).String$(String options)Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).voidbeforeRender(Component component)
Also,beforeRender(Component)will callIJQueryWidget.onBeforeRender(JQueryBehavior)(if the component IS-AIJQueryWidget)
If a property is set inbeforeRender(Component)and is needed inIJQueryWidget.onBeforeRender(JQueryBehavior),super.beforeRender(component)should be the last statement.voiddetach(IPartialPageRequestHandler handler)Removes the element matching the current selector from the DOM.
The#detachmethod is the same as#remove, except that#detachkeeps all jQuery data associated with the removed elements.
This method is useful when removed elements are to be reinserted into the DOM at a later time.StringgetMethod()Gets the jQuery method<T> TgetOption(String key)Gets a behavior option, referenced by its keyOptionsgetOptions()Gets theOptionsStringgetSelector()Gets the selectorprotected voidoff(String selector, String event)Unregisters a jQuery event callbackprotected voidon(String event, String callback)Registers a jQuery event callbackprotected voidon(String selector, String event, String callback)Registers a jQuery event callbackvoidonConfigure(Component component)
Also,onConfigure(Component)will callIJQueryWidget.onConfigure(JQueryBehavior)(if the component IS-AIJQueryWidget)
If a property is set inonConfigure(Component)and is needed inIJQueryWidget.onConfigure(JQueryBehavior),super.onConfigure(component)should be the last statement.protected voidregister(String statement)Registers a jQuery event statementvoidremove(IPartialPageRequestHandler handler)Removes the element matching the current selector from the DOM.
Use#removewhen you want to remove the element itself, as well as everything inside it.
In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.
To remove the elements without removing data and events, use#detachinstead.voidrenderHead(Component component, IHeaderResponse response)JQueryBehaviorsetOption(String key, Object value)Sets a behavior option.JQueryBehaviorsetOption(String key, Object... values)Sets a behavior option, with multiple values.JQueryBehaviorsetOption(String key, List<?> values)Sets a behavior option, with multiple values.voidsetOptions(Options options)Adds or replace behavior optionsprotected voidsetSelector(String selector)Sets the selector-
Methods inherited from class com.googlecode.wicket.jquery.core.JQueryAbstractBehavior
add, getJQueryLibrarySettings, renderOnDomReadyScript, renderPriorityHeaderItem, toString
-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, bind, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onComponentTag, onEvent, onException, onRemove, onTag, unbind
-
-
-
-
Constructor Detail
-
JQueryBehavior
public JQueryBehavior(String selector)
Constructor- Parameters:
selector- the html selector (ie: "#myId")
-
JQueryBehavior
public JQueryBehavior(String selector, String method)
Constructor- Parameters:
selector- the html selector (ie: "#myId")method- the jquery method
-
-
Method Detail
-
renderHead
public void renderHead(Component component, IHeaderResponse response)
- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classJQueryAbstractBehavior
-
detach
public void detach(IPartialPageRequestHandler handler)
Removes the element matching the current selector from the DOM.
The#detachmethod is the same as#remove, except that#detachkeeps all jQuery data associated with the removed elements.
This method is useful when removed elements are to be reinserted into the DOM at a later time.- Parameters:
handler- theIPartialPageRequestHandler- See Also:
remove(IPartialPageRequestHandler)
-
remove
public void remove(IPartialPageRequestHandler handler)
Removes the element matching the current selector from the DOM.
Use#removewhen you want to remove the element itself, as well as everything inside it.
In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.
To remove the elements without removing data and events, use#detachinstead.- Parameters:
handler- theIPartialPageRequestHandler- See Also:
detach(IPartialPageRequestHandler)
-
getSelector
public String getSelector()
Gets the selector- Returns:
- the selector
-
setSelector
protected void setSelector(String selector)
Sets the selector- Parameters:
selector- the html selector (ie: "#myId")
-
getMethod
public String getMethod()
Gets the jQuery method- Returns:
- the method
-
getOption
public <T> T getOption(String key)
Gets a behavior option, referenced by its key- Type Parameters:
T- the object type- Parameters:
key- the option key- Returns:
nullif the key does not exists
-
setOption
public JQueryBehavior setOption(String key, Object value)
Sets a behavior option.- Parameters:
key- the option keyvalue- the option value- Returns:
- the
JQueryBehavior(this)
-
setOption
public JQueryBehavior setOption(String key, Object... values)
Sets a behavior option, with multiple values.- Parameters:
key- the option keyvalues- the option values- Returns:
- the
JQueryBehavior(this)
-
setOption
public JQueryBehavior setOption(String key, List<?> values)
Sets a behavior option, with multiple values.- Parameters:
key- the option keyvalues- the option values- Returns:
- the
JQueryBehavior(this)
-
setOptions
public void setOptions(Options options)
Adds or replace behavior options- Parameters:
options- theOptions
-
on
protected void on(String event, String callback)
Registers a jQuery event callback- Parameters:
event- the jQuery event (ie: "click")callback- the jQuery callback
-
on
protected void on(String selector, String event, String callback)
Registers a jQuery event callback- Parameters:
selector- the html selector (ie: "#myId")event- the jQuery event (ie: "click")callback- the jQuery callback
-
off
protected void off(String selector, String event)
Unregisters a jQuery event callback- Parameters:
selector- the html selector (ie: "#myId")event- the jQuery event (ie: "click")
-
register
protected void register(String statement)
Registers a jQuery event statement- Parameters:
statement- the jQuery statement (ie: "jQuery('#myId').on('click', function() {});")
-
$
protected String $()
Description copied from class:JQueryAbstractBehaviorGets the jQuery statement.- Specified by:
$in classJQueryAbstractBehavior- Returns:
- the jQuery statement
-
$
public String $(String options)
Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).- Parameters:
options- the options to be supplied to the current method- Returns:
- the jQuery statement
-
$
public String $(Options options)
Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).- Parameters:
options- theOptionsto be supplied to the current method- Returns:
- the jQuery statement
-
$
public String $(Object... options)
Gets the jQuery statement.
Warning: This method is *not* called by the behavior directly (only$()is).- Parameters:
options- the list of options to be supplied to the current method- Returns:
- the jQuery statement
-
onConfigure
public void onConfigure(Component component)
Also,onConfigure(Component)will callIJQueryWidget.onConfigure(JQueryBehavior)(if the component IS-AIJQueryWidget)
If a property is set inonConfigure(Component)and is needed inIJQueryWidget.onConfigure(JQueryBehavior),super.onConfigure(component)should be the last statement.- Overrides:
onConfigurein classBehavior
-
beforeRender
public void beforeRender(Component component)
Also,beforeRender(Component)will callIJQueryWidget.onBeforeRender(JQueryBehavior)(if the component IS-AIJQueryWidget)
If a property is set inbeforeRender(Component)and is needed inIJQueryWidget.onBeforeRender(JQueryBehavior),super.beforeRender(component)should be the last statement.- Overrides:
beforeRenderin classBehavior
-
-