Class CallbackParameter


  • public class CallbackParameter
    extends Object
    CallbackParameter is a specification of a parameter that is used in an AJAX callback function. It specifies if and how the parameter is added to the function declaration, if and how it is added to the AJAX callback and what code to use to generate the contents.
    Author:
    papegaaij
    • Method Detail

      • context

        public static CallbackParameter context​(String name)
        Add a parameter to the function declaration. This parameter will not be passed to the AJAX callback. For example, the following code:
         
         	getCallbackFunction(context("event"), context("ui"));
         
         
        generates a function with two parameters, like function(event, ui) {...}.
        Parameters:
        name -
        Returns:
        The parameter
      • explicit

        public static CallbackParameter explicit​(String name)
        Add a parameter to the function declaration that is also passed to the AJAX callback. For example, the following code:
         
         	getCallbackFunction(explicit("param"));
         
         
        generates a function with one parameter, like function(param) {...} where 'param' is passed literally as extra parameter to the AJAX callback.
        Parameters:
        name -
        Returns:
        The parameter
      • resolved

        public static CallbackParameter resolved​(String name,
                                                 String code)
        Add a parameter to the AJAX callback that is resolved inside the function, it will not be added as function parameter. For example, the following code:
         
         	getCallbackFunction(resolved("param", "global.substring(0, 3)"));
         
         
        generates a function without parameters, like function() {...} where the first 3 characters of the global variable 'global' are passed as extra parameter to the AJAX callback under the name 'param'.
        Parameters:
        name -
        code -
        Returns:
        The parameter
      • converted

        public static CallbackParameter converted​(String name,
                                                  String code)
        Add a parameter to the function declaration that is also passed to the AJAX callback, but converted. For example, the following code:
         
         	getCallbackFunction(converted("param", "param.substring(0, 3)"));
         
         
        generates a function with one parameter, like function(param) {...} where the first 3 characters of 'param' are passed as extra parameter to the AJAX callback.
        Parameters:
        name -
        code -
        Returns:
        The parameter
      • getFunctionParameterName

        public String getFunctionParameterName()
        Returns:
        the name of the parameter to add to the function declaration, or null if no parameter should be added.
      • getAjaxParameterName

        public String getAjaxParameterName()
        Returns:
        the name of the parameter to add to the AJAX callback, or null if no parameter should be added.
      • getAjaxParameterCode

        public String getAjaxParameterCode()
        Returns:
        the javascript code to use to fill the parameter for the AJAX callback.