Class AjaxCallListener

    • Method Detail

      • onInit

        public AjaxCallListener onInit​(CharSequence init)
        Sets the JavaScript code that will be returned by getInitHandler(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​(CharSequence done)
        Sets the JavaScript code that will be returned by getDoneHandler(Component). If this code was already set, the new one will be appended to the existing one.
        Parameters:
        done - the JavaScript code for the corresponding handler
        Returns:
        This
      • onAfter

        public AjaxCallListener onAfter​(CharSequence after)
        Sets the JavaScript code that will be returned by getAfterHandler(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
      • 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
        2. jqXHR - the jQuery XMLHttpRequest object
        3. errorMessage - in case of HTTP error the textual portion of the HTTP status
        4. textStatus - type of failure: null, "timeout", "error", "abort" or "parsererror"
        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.
      • getInitHandler

        public CharSequence getInitHandler​(Component component)
        Description copied from interface: IAjaxCallListener
        The 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:
        1. attrs - the AjaxRequestAttributes as JSON
        Specified by:
        getInitHandler in interface IAjaxCallListener
        Parameters:
        component - the Component with the Ajax behavior
        Returns:
        the JavaScript that will be executed on initialization 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.
      • getDoneHandler

        public CharSequence getDoneHandler​(Component component)
        Description copied from interface: IAjaxCallListener
        The 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:
        1. attrs - the AjaxRequestAttributes as JSON
        Specified by:
        getDoneHandler in interface IAjaxCallListener
        Parameters:
        component - the Component with the Ajax behavior
        Returns:
        the JavaScript that will be executed after the Ajax call is done.