org.apache.wicket.ajax.attributes
Class AjaxCallListener

java.lang.Object
  extended by org.apache.wicket.ajax.attributes.AjaxCallListener
All Implemented Interfaces:
Serializable, IAjaxCallListener, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
CancelEventIfAjaxListener

public class AjaxCallListener
extends Object
implements IAjaxCallListener, IComponentAwareHeaderContributor

An adapter for implementations of IAjaxCallListener.

Since:
6.0
See Also:
Serialized Form

Constructor Summary
AjaxCallListener()
           
 
Method Summary
 CharSequence getAfterHandler(Component component)
          The JavaScript that will be executed after the Ajax call.
 CharSequence getBeforeHandler(Component component)
          The JavaScript that will be executed before the Ajax call, as early as possible.
 CharSequence getBeforeSendHandler(Component component)
          The JavaScript that will be executed right before the execution of the the Ajax call, only if all preconditions pass.
 CharSequence getCompleteHandler(Component component)
          The JavaScript that will be executed after both successful and unsuccessful return of the Ajax call.
 CharSequence getFailureHandler(Component component)
          The JavaScript that will be executed after unsuccessful return of the Ajax call.
 CharSequence getPrecondition(Component component)
          A JavaScript function that is invoked before the request is being executed.
 CharSequence getSuccessHandler(Component component)
          The JavaScript that will be executed after successful return of the Ajax call.
 AjaxCallListener onAfter(CharSequence after)
           
 AjaxCallListener onBefore(CharSequence before)
           
 AjaxCallListener onBeforeSend(CharSequence beforeSend)
           
 AjaxCallListener onComplete(CharSequence complete)
           
 AjaxCallListener onFailure(CharSequence failure)
           
 AjaxCallListener onPrecondition(CharSequence precondition)
           
 AjaxCallListener onSuccess(CharSequence success)
           
 void renderHead(Component component, IHeaderResponse response)
          Render to the web response whatever the component-aware wants to contribute to the head section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxCallListener

public AjaxCallListener()
Method Detail

onBefore

public AjaxCallListener onBefore(CharSequence before)

onBeforeSend

public AjaxCallListener onBeforeSend(CharSequence beforeSend)

onAfter

public AjaxCallListener onAfter(CharSequence after)

onSuccess

public AjaxCallListener onSuccess(CharSequence success)

onFailure

public AjaxCallListener onFailure(CharSequence failure)

onComplete

public AjaxCallListener onComplete(CharSequence complete)

onPrecondition

public AjaxCallListener onPrecondition(CharSequence precondition)

getSuccessHandler

public CharSequence getSuccessHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed after successful return of the Ajax call. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON
  2. jqXHR - the jQuery XMLHttpRequest object
  3. data - the Ajax response. Its type depends on AjaxRequestAttributes.dataType
  4. textStatus - the status as text

Specified by:
getSuccessHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed after a successful return of the Ajax call.

getFailureHandler

public CharSequence getFailureHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed after unsuccessful return of the Ajax call. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON

Specified by:
getFailureHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed after a unsuccessful return of the Ajax call.

getBeforeHandler

public CharSequence getBeforeHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed before the Ajax call, as early as possible. Even before the preconditions. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON

Specified by:
getBeforeHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed before the Ajax call.

getBeforeSendHandler

public CharSequence getBeforeSendHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed right before the execution of the the Ajax call, only if all preconditions pass. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON
  2. jqXHR - the jQuery XMLHttpRequest object
  3. settings - the settings used for the jQuery.ajax() call

Specified by:
getBeforeSendHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed before the Ajax call.

getAfterHandler

public CharSequence getAfterHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed after the Ajax call. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON
Note: if the Ajax call is synchronous (see AjaxRequestAttributes.setAsynchronous(boolean)) then this JavaScript will be executed after the complete handler, otherwise it is executed right after the execution of the Ajax request.

Specified by:
getAfterHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed after the start of the Ajax call but before its response is returned.

getCompleteHandler

public CharSequence getCompleteHandler(Component component)
Description copied from interface: IAjaxCallListener
The JavaScript that will be executed after both successful and unsuccessful return of the Ajax call. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON
  2. jqXHR - the jQuery XMLHttpRequest object
  3. textStatus - the status as text

Specified by:
getCompleteHandler in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that will be executed after both successful and unsuccessful return of the Ajax call.

getPrecondition

public CharSequence getPrecondition(Component component)
Description copied from interface: IAjaxCallListener
A JavaScript function that is invoked before the request is being executed. If it returns false then the execution of the Ajax call will be cancelled. The script will be executed in a function that receives the following parameters:
  1. attrs - the AjaxRequestAttributes as JSON

Specified by:
getPrecondition in interface IAjaxCallListener
Parameters:
component - the Component with the Ajax behavior
Returns:
the JavaScript that should be used to decide whether the Ajax call should be made at all.

renderHead

public void renderHead(Component component,
                       IHeaderResponse response)
Description copied from interface: IComponentAwareHeaderContributor
Render to the web response whatever the component-aware wants to contribute to the head section.

Specified by:
renderHead in interface IComponentAwareHeaderContributor
Parameters:
component - component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interface
response - Response object


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.