Class AjaxCallListener
- java.lang.Object
-
- org.apache.wicket.ajax.attributes.AjaxCallListener
-
- All Implemented Interfaces:
java.io.Serializable,IAjaxCallListener,IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
CancelEventIfAjaxListener
public class AjaxCallListener extends java.lang.Object implements IAjaxCallListener, IComponentAwareHeaderContributor
An adapter for implementations of IAjaxCallListener.- Since:
- 6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AjaxCallListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.CharSequencegetAfterHandler(Component component)The JavaScript that will be executed after the Ajax call.java.lang.CharSequencegetBeforeHandler(Component component)The JavaScript that will be executed before the Ajax call, as early as possible.java.lang.CharSequencegetBeforeSendHandler(Component component)The JavaScript that will be executed right before the execution of the the Ajax call, only if all preconditions pass.java.lang.CharSequencegetCompleteHandler(Component component)The JavaScript that will be executed after both successful and unsuccessful return of the Ajax call.java.lang.CharSequencegetDoneHandler(Component component)The JavaScript that will be executed after the Ajax call is done, regardless whether it was sent or not.java.lang.CharSequencegetFailureHandler(Component component)The JavaScript that will be executed after unsuccessful return of the Ajax call.java.lang.CharSequencegetInitHandler(Component component)The JavaScript that will be executed on initialization of the Ajax call, immediately after the causing event.java.lang.CharSequencegetPrecondition(Component component)A JavaScript function that is invoked before the request is being executed.java.lang.CharSequencegetSuccessHandler(Component component)The JavaScript that will be executed after successful return of the Ajax call.AjaxCallListeneronAfter(java.lang.CharSequence after)Sets the JavaScript code that will be returned bygetAfterHandler(Component).AjaxCallListeneronBefore(java.lang.CharSequence before)Sets the JavaScript code that will be returned bygetBeforeHandler(Component).AjaxCallListeneronBeforeSend(java.lang.CharSequence beforeSend)Sets the JavaScript code that will be returned bygetBeforeSendHandler(Component).AjaxCallListeneronComplete(java.lang.CharSequence complete)Sets the JavaScript code that will be returned bygetCompleteHandler(Component).AjaxCallListeneronDone(java.lang.CharSequence done)Sets the JavaScript code that will be returned bygetDoneHandler(Component).AjaxCallListeneronFailure(java.lang.CharSequence failure)Sets the JavaScript code that will be returned bygetFailureHandler(Component).AjaxCallListeneronInit(java.lang.CharSequence init)Sets the JavaScript code that will be returned bygetInitHandler(Component).AjaxCallListeneronPrecondition(java.lang.CharSequence precondition)Sets the JavaScript code that will be returned bygetPrecondition(Component).AjaxCallListeneronSuccess(java.lang.CharSequence success)Sets the JavaScript code that will be returned bygetSuccessHandler(Component).voidrenderHead(Component component, IHeaderResponse response)Render to the web response whatever the component-aware wants to contribute to the head section.
-
-
-
Method Detail
-
onInit
public AjaxCallListener onInit(java.lang.CharSequence init)
Sets the JavaScript code that will be returned bygetInitHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
init- the JavaScript code for the corresponding handler- Returns:
- This
-
onDone
public AjaxCallListener onDone(java.lang.CharSequence done)
Sets the JavaScript code that will be returned bygetDoneHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
init- the JavaScript code for the corresponding handler- Returns:
- This
-
onBefore
public AjaxCallListener onBefore(java.lang.CharSequence before)
Sets the JavaScript code that will be returned bygetBeforeHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
before- the JavaScript code for the corresponding handler- Returns:
- This
-
onBeforeSend
public AjaxCallListener onBeforeSend(java.lang.CharSequence beforeSend)
Sets the JavaScript code that will be returned bygetBeforeSendHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
beforeSend- the JavaScript code for the corresponding handler- Returns:
- This
-
onAfter
public AjaxCallListener onAfter(java.lang.CharSequence after)
Sets the JavaScript code that will be returned bygetAfterHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
after- the JavaScript code for the corresponding handler- Returns:
- This
-
onSuccess
public AjaxCallListener onSuccess(java.lang.CharSequence success)
Sets the JavaScript code that will be returned bygetSuccessHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
success- the JavaScript code for the corresponding handler- Returns:
- This
-
onFailure
public AjaxCallListener onFailure(java.lang.CharSequence failure)
Sets the JavaScript code that will be returned bygetFailureHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
failure- the JavaScript code for the corresponding handler- Returns:
- This
-
onComplete
public AjaxCallListener onComplete(java.lang.CharSequence complete)
Sets the JavaScript code that will be returned bygetCompleteHandler(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
complete- the JavaScript code for the corresponding handler- Returns:
- This
-
onPrecondition
public AjaxCallListener onPrecondition(java.lang.CharSequence precondition)
Sets the JavaScript code that will be returned bygetPrecondition(Component). If this code was already set, the new one will be appended to the existing one.- Parameters:
precondition- the JavaScript code for the precondition- Returns:
- This
-
getSuccessHandler
public java.lang.CharSequence getSuccessHandler(Component component)
Description copied from interface:IAjaxCallListenerThe 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:- attrs - the AjaxRequestAttributes as JSON
- jqXHR - the jQuery XMLHttpRequest object
- data - the Ajax response. Its type depends on
AjaxRequestAttributes.dataType - textStatus - the status as text
- Specified by:
getSuccessHandlerin interfaceIAjaxCallListener- 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 java.lang.CharSequence getFailureHandler(Component component)
Description copied from interface:IAjaxCallListenerThe 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:- attrs - the AjaxRequestAttributes as JSON
- jqXHR - the jQuery XMLHttpRequest object
- errorMessage - in case of HTTP error the textual portion of the HTTP status
- textStatus - type of failure: null, "timeout", "error", "abort" or "parsererror"
- Specified by:
getFailureHandlerin interfaceIAjaxCallListener- Parameters:
component- the Component with the Ajax behavior- Returns:
- the JavaScript that will be executed after a unsuccessful return of the Ajax call.
-
getInitHandler
public java.lang.CharSequence getInitHandler(Component component)
Description copied from interface:IAjaxCallListenerThe JavaScript that will be executed on initialization of the Ajax call, immediately after the causing event. The script will be executed in a function that receives the following parameters:- attrs - the AjaxRequestAttributes as JSON
- Specified by:
getInitHandlerin interfaceIAjaxCallListener- Parameters:
component- the Component with the Ajax behavior- Returns:
- the JavaScript that will be executed on initialization of the Ajax call.
-
getBeforeHandler
public java.lang.CharSequence getBeforeHandler(Component component)
Description copied from interface:IAjaxCallListenerThe 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:- attrs - the AjaxRequestAttributes as JSON
- Specified by:
getBeforeHandlerin interfaceIAjaxCallListener- Parameters:
component- the Component with the Ajax behavior- Returns:
- the JavaScript that will be executed before the Ajax call.
-
getBeforeSendHandler
public java.lang.CharSequence getBeforeSendHandler(Component component)
Description copied from interface:IAjaxCallListenerThe 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:- attrs - the AjaxRequestAttributes as JSON
- jqXHR - the jQuery XMLHttpRequest object
- settings - the settings used for the jQuery.ajax() call
- Specified by:
getBeforeSendHandlerin interfaceIAjaxCallListener- Parameters:
component- the Component with the Ajax behavior- Returns:
- the JavaScript that will be executed before the Ajax call.
-
getAfterHandler
public java.lang.CharSequence getAfterHandler(Component component)
Description copied from interface:IAjaxCallListenerThe JavaScript that will be executed after the Ajax call. The script will be executed in a function that receives the following parameters:- attrs - the AjaxRequestAttributes as JSON
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:
getAfterHandlerin interfaceIAjaxCallListener- 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 java.lang.CharSequence getCompleteHandler(Component component)
Description copied from interface:IAjaxCallListenerThe 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:- attrs - the AjaxRequestAttributes as JSON
- jqXHR - the jQuery XMLHttpRequest object
- textStatus - the status as text
- Specified by:
getCompleteHandlerin interfaceIAjaxCallListener- 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 java.lang.CharSequence getPrecondition(Component component)
Description copied from interface:IAjaxCallListenerA JavaScript function that is invoked before the request is being executed. If it returnsfalsethen the execution of the Ajax call will be cancelled. The script will be executed in a function that receives the following parameters:- attrs - the AjaxRequestAttributes as JSON
- Specified by:
getPreconditionin interfaceIAjaxCallListener- 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.
-
getDoneHandler
public java.lang.CharSequence getDoneHandler(Component component)
Description copied from interface:IAjaxCallListenerThe JavaScript that will be executed after the Ajax call is done, regardless whether it was sent or not. The script will be executed in a function that receives the following parameters:- attrs - the AjaxRequestAttributes as JSON
- Specified by:
getDoneHandlerin interfaceIAjaxCallListener- Parameters:
component- the Component with the Ajax behavior- Returns:
- the JavaScript that will be executed after the Ajax call is done.
-
renderHead
public void renderHead(Component component, IHeaderResponse response)
Description copied from interface:IComponentAwareHeaderContributorRender to the web response whatever the component-aware wants to contribute to the head section.- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- 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 interfaceresponse- Response object
-
-