org.odlabs.wiquery.ui.selectable
Class SelectableAjaxBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.odlabs.wiquery.core.behavior.WiQueryAbstractAjaxBehavior
                  extended by org.odlabs.wiquery.ui.selectable.SelectableAjaxBehavior
All Implemented Interfaces:
Serializable, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.IClusterable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IComponentAwareHeaderContributor, IWiQueryPlugin

public abstract class SelectableAjaxBehavior
extends WiQueryAbstractAjaxBehavior

$Id: SelectableAjaxBehavior

Sets the attached component selectable behavior. When the user finished to select some childs components,onSelection(Component[], AjaxRequestTarget) is called via Ajax.

This behavior contains a SelectableBehavior which is used to control the options of the selectable, including all the options and event of the behavior. Example:

 SelectableAjaxBehavior selectable = new SelectableAjaxBehavior() {
                public void onSelection(Component[] components, AjaxRequestTarget ajaxRequestTarget) {
                        ...
                }
 }
 SelectableBehavior sb = selectable.getSelectableBehavior();
 sb.setTolerance(ToleranceEnum.FIT);
 add(selectable);
 

Since:
1.0
Author:
Julien Roche
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
SelectableAjaxBehavior()
          Default constructor
 
Method Summary
 JsStatement destroy()
          Method to destroy This will return the element back to its pre-init state.
 void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to destroy within the ajax request
 JsStatement disable()
          Method to disable
 void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to disable within the ajax request
 JsStatement enable()
          Method to enable
 void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to enable within the ajax request
protected  CharSequence getCallbackScript()
          We override super method to add the selected array to the URL.
 String getCancel()
           
 int getDelay()
           
 int getDistance()
           
 String getFilter()
           
 SelectableBehavior getSelectableBehavior()
           
 SelectableBehavior.ToleranceEnum getTolerance()
           
 boolean isAutoRefresh()
           
 boolean isDisabled()
           
protected  void onBind()
           
 void onSelection(org.apache.wicket.ajax.AjaxRequestTarget target)
          For framework internal use only.
abstract  void onSelection(org.apache.wicket.Component[] components, org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          onSelection is triggered at the end of a selection operation.
 JsStatement refresh()
          Method to refresh
 void refresh(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to refresh within the ajax request
protected  void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
           
 SelectableAjaxBehavior setAutoRefresh(boolean autoRefresh)
          This determines whether to refresh (recalculate) the position and size of each selected at the beginning of each select operation.
 SelectableAjaxBehavior setCancel(String cancel)
          Set's the prevent selecting if you start on elements matching the selector
 SelectableAjaxBehavior setDelay(int delay)
          Set's the delay (in milliseconds) to define when the selecting should start
 SelectableAjaxBehavior setDisabled(boolean disabled)
          Disables (true) or enables (false) the selectable.
 SelectableAjaxBehavior setDistance(int distance)
          Set's the tolerance in pixels
 SelectableAjaxBehavior setFilter(String filter)
          Set's the matching child to be selectable
 SelectableAjaxBehavior setTolerance(SelectableBehavior.ToleranceEnum tolerance)
          Set's the tolerance fit: draggable overlaps the droppable entirely touch: draggable overlaps the droppable any amount
 JsStatement statement()
          Returns the main JsStatement used to create the plugin.
 JsStatement widget()
          Method to returns the .ui-selectable element
 void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to returns the .ui-selectable element within the ajax request
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getChannel, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onRequest, renderHead, throttleScript
 
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, getStatelessHint, onComponentRendered, onComponentTag, onComponentTag
 
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListenerInterface, canCallListenerInterface, detach, isEnabled, isTemporary, onConfigure, onEvent, onException, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectableAjaxBehavior

public SelectableAjaxBehavior()
Default constructor

Method Detail

getCallbackScript

protected CharSequence getCallbackScript()
We override super method to add the selected array to the URL. Otherwise we use standard AbstractDefaultAjaxBehavior machinery to generate script: what way all the logic regarding IAjaxCallDecorator or indicatorId will be added to the generated script. This makes selectable AJAX behavior compatible with standard Wicket's AJAX call-backs.

Overrides:
getCallbackScript in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
See Also:
AbstractAjaxBehavior.getCallbackUrl()

getSelectableBehavior

public SelectableBehavior getSelectableBehavior()
Returns:
the standard Selectable JavaScript behavior

onBind

protected void onBind()
Overrides:
onBind in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior

onSelection

public final void onSelection(org.apache.wicket.ajax.AjaxRequestTarget target)
For framework internal use only.


onSelection

public abstract void onSelection(org.apache.wicket.Component[] components,
                                 org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
onSelection is triggered at the end of a selection operation.

Parameters:
components - List of components selected
ajaxRequestTarget - the Ajax target

respond

protected void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
Specified by:
respond in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior

statement

public JsStatement statement()
Description copied from interface: IWiQueryPlugin
Returns the main JsStatement used to create the plugin.

Specified by:
statement in interface IWiQueryPlugin
Specified by:
statement in class WiQueryAbstractAjaxBehavior
Returns:
The JsStatement corresponding to this component.

getCancel

public String getCancel()
Returns:
the cancel option value

getDelay

public int getDelay()
Returns:
the delay option value

getDistance

public int getDistance()
Returns:
the distance option value

getFilter

public String getFilter()
Returns:
the cancel option value

getTolerance

public SelectableBehavior.ToleranceEnum getTolerance()
Returns:
the tolerance option enum

isAutoRefresh

public boolean isAutoRefresh()
Returns:
the autoRefresh option enum

setAutoRefresh

public SelectableAjaxBehavior setAutoRefresh(boolean autoRefresh)
This determines whether to refresh (recalculate) the position and size of each selected at the beginning of each select operation. If you have many many items, you may want to set this to false and call the refresh method manually.

Parameters:
autoRefresh -
Returns:
instance of the current behavior

setDisabled

public SelectableAjaxBehavior setDisabled(boolean disabled)
Disables (true) or enables (false) the selectable. Can be set when initialising (first creating) the selectable.

Parameters:
disabled -
Returns:
instance of the current behavior

isDisabled

public boolean isDisabled()
Returns:
the disabled option

setCancel

public SelectableAjaxBehavior setCancel(String cancel)
Set's the prevent selecting if you start on elements matching the selector

Parameters:
cancel - Selector (default : ':input,option')
Returns:
instance of the current behavior

setDelay

public SelectableAjaxBehavior setDelay(int delay)
Set's the delay (in milliseconds) to define when the selecting should start

Parameters:
delay -
Returns:
instance of the current behavior

setDistance

public SelectableAjaxBehavior setDistance(int distance)
Set's the tolerance in pixels

Parameters:
distance -
Returns:
instance of the current behavior

setFilter

public SelectableAjaxBehavior setFilter(String filter)
Set's the matching child to be selectable

Parameters:
filter - Selector (default : '*')
Returns:
instance of the current behavior

setTolerance

public SelectableAjaxBehavior setTolerance(SelectableBehavior.ToleranceEnum tolerance)
Set's the tolerance

Parameters:
tolerance -
Returns:
instance of the current behavior

destroy

public JsStatement destroy()
Method to destroy This will return the element back to its pre-init state.

Returns:
the associated JsStatement

destroy

public void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to destroy within the ajax request

Parameters:
ajaxRequestTarget -

disable

public JsStatement disable()
Method to disable

Returns:
the associated JsStatement

disable

public void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to disable within the ajax request

Parameters:
ajaxRequestTarget -

enable

public JsStatement enable()
Method to enable

Returns:
the associated JsStatement

enable

public void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to enable within the ajax request

Parameters:
ajaxRequestTarget -

refresh

public JsStatement refresh()
Method to refresh

Returns:
the associated JsStatement

refresh

public void refresh(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to refresh within the ajax request

Parameters:
ajaxRequestTarget -

widget

public JsStatement widget()
Method to returns the .ui-selectable element

Returns:
the associated JsStatement

widget

public void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to returns the .ui-selectable element within the ajax request

Parameters:
ajaxRequestTarget -


Copyright © 2012. All Rights Reserved.