org.wicketstuff.jquery.dnd
Class DnDSortableBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.wicketstuff.jquery.JQueryBehavior
                  extended by org.wicketstuff.jquery.dnd.DnDSortableBehavior
All Implemented Interfaces:
Serializable, org.apache.wicket.behavior.IBehavior, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.behavior.IComponentConfigurationBehavior, org.apache.wicket.IClusterable, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IHeaderContributor

public class DnDSortableBehavior
extends JQueryBehavior
implements org.apache.wicket.behavior.IBehaviorListener

See Also:
Serialized Form

Field Summary
protected  ArrayList<org.apache.wicket.MarkupContainer> containers_
           
static org.apache.wicket.markup.html.resources.CompressedResourceReference DNDSORTABLEBEHAVIOR_JS
           
protected  Options options_
           
 
Fields inherited from class org.wicketstuff.jquery.JQueryBehavior
INTERFACE_JS, JQUERY_BGIFRAME_JS, JQUERY_DEBUG_JS, JQUERY_JS, JQUERY_REGEXP, JQUERY_UI_JS
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
DnDSortableBehavior()
           
DnDSortableBehavior(Options options)
          Create a DnDSortableBehavior with default options override.
 
Method Summary
 CharSequence getJSFunctionName4Start()
           
 CharSequence getJSFunctionName4Stop()
           
 String getOnReadyScript()
          to be override by subclass if need to run script when dom is ready.
 CharSequence getRebindScript()
           
 boolean onDnD(org.apache.wicket.ajax.AjaxRequestTarget target, org.apache.wicket.MarkupContainer srcContainer, int srcPos, org.apache.wicket.MarkupContainer destContainer, int destPos)
          Call when a component has been moved on client side (to be overwrited).
 void onDnD(org.apache.wicket.ajax.AjaxRequestTarget target, String srcContainerId, int srcPos, String destContainerId, int destPos)
          Call when a component has been moved on client side.
protected  DnDSortableBehavior registerContainer(org.apache.wicket.MarkupContainer v)
          Register a container as a container for draggable/droppable items.
protected  DnDSortableBehavior registerItem(org.apache.wicket.Component v)
          Register a component as draggable/moveable item.
 void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
           
 void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
           
 
Methods inherited from class org.wicketstuff.jquery.JQueryBehavior
getIncludeJQueryJS, logger
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getCallbackScript, getCallbackScript, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onBind, onRequest, throttleScript
 
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
bind, getCallbackUrl, getCallbackUrl, getComponent, getImplementationId, getStatelessHint, onComponentRendered, onComponentTag, onComponentTag, onRendered, onRenderHeadContribution, onRenderHeadInitContribution
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, cleanup, detach, detachModel, exception, isEnabled, isTemporary, onConfigure, onException, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.behavior.IBehaviorListener
onRequest
 

Field Detail

DNDSORTABLEBEHAVIOR_JS

public static final org.apache.wicket.markup.html.resources.CompressedResourceReference DNDSORTABLEBEHAVIOR_JS

options_

protected Options options_

containers_

protected ArrayList<org.apache.wicket.MarkupContainer> containers_
Constructor Detail

DnDSortableBehavior

public DnDSortableBehavior()

DnDSortableBehavior

public DnDSortableBehavior(Options options)
Create a DnDSortableBehavior with default options override.
Method Detail

renderHead

public void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor
Overrides:
renderHead in class JQueryBehavior

getRebindScript

public CharSequence getRebindScript()

getOnReadyScript

public String getOnReadyScript()
Description copied from class: JQueryBehavior
to be override by subclass if need to run script when dom is ready. The returned script is wrapped by caller into <script> tag and the "$(document).ready(function(){...}"

Overrides:
getOnReadyScript in class JQueryBehavior
Returns:
the script to execute when the dom is ready, or null (default)

getJSFunctionName4Start

public CharSequence getJSFunctionName4Start()
Returns:
the name of the javascript function to start the behavior on client side.

getJSFunctionName4Stop

public CharSequence getJSFunctionName4Stop()
Returns:
the name of the javascript function to stop the behavior on client side.

respond

public final void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
Overrides:
respond in class JQueryBehavior

onDnD

public void onDnD(org.apache.wicket.ajax.AjaxRequestTarget target,
                  String srcContainerId,
                  int srcPos,
                  String destContainerId,
                  int destPos)
Call when a component has been moved on client side. The default implementation log (as debug) the incomming parameters, search the component and forward to onDnD(AjaxRequestTarget target, String itemId, String srcContainerId, int srcPos, String destContainerId, int destPos).

Parameters:
target - a target, provide if a response,
srcContainerId - the html id of source container from where item come, (null if not previously registered by via registerContainer(...)).
srcPos - the position/index of item into srcContainer before moving.
destContainerId - the html id of destination container where item is, (null if not previously registered by via registerContainer(...)).
destPos - the position/index of item into srcContainer after moving.

onDnD

public boolean onDnD(org.apache.wicket.ajax.AjaxRequestTarget target,
                     org.apache.wicket.MarkupContainer srcContainer,
                     int srcPos,
                     org.apache.wicket.MarkupContainer destContainer,
                     int destPos)
Call when a component has been moved on client side (to be overwrited). The default implementation log (as debug) the incomming parameters.

Parameters:
target - a target, provide if a response,
srcContainer - the source container from where item come, (null if not previously registered by via registerContainer(...)).
srcPos - the position/index of item into srcContainer before moving.
destContainer - the destination container where item is, (null if not previously registered by via registerContainer(...)).
destPos - the position/index of item into srcContainer after moving.
Returns:
false if you don't need to keep in sync component, markupId on serverside and client side, else return true to send to client side the srcContainer and destContainer and to update the handler (consume more resource, server, network, client).

registerContainer

protected DnDSortableBehavior registerContainer(org.apache.wicket.MarkupContainer v)
Register a container as a container for draggable/droppable items. (add the css class and markupId to be find on clientside).

Parameters:
v - the container to register.
Returns:
this

registerItem

protected DnDSortableBehavior registerItem(org.apache.wicket.Component v)
Register a component as draggable/moveable item. (add the css class and markupId to be find on clientside).

Parameters:
v - the component to register.
Returns:
this


Copyright © 2012. All Rights Reserved.