Class JQueryAjaxOption
- java.lang.Object
-
- org.wicketstuff.wiquery.core.ajax.JQueryAjaxOption
-
- All Implemented Interfaces:
java.io.Serializable,org.apache.wicket.model.IDetachable,org.apache.wicket.model.IModel<JQueryAjaxOption>,org.apache.wicket.util.io.IClusterable,IComplexOption
public class JQueryAjaxOption extends java.lang.Object implements IComplexOption, org.apache.wicket.model.IModel<JQueryAjaxOption>
$Id: JQueryAjaxOptionsBean storing jQuery Ajax options
- Since:
- 1.0
- Author:
- Julien Roche
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJQueryAjaxOption.AjaxTypeEnumeration of Ajax type
-
Constructor Summary
Constructors Constructor Description JQueryAjaxOption()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddetach()java.lang.StringgetContentType()java.lang.StringgetData()java.lang.StringgetDataType()java.lang.CharSequencegetJavascriptOption()Method retrieving the javascript representation of this complex optionjava.lang.StringgetJsonp()JQueryAjaxOptiongetObject()protected OptionsgetOptions()Method retrieving the optionsjava.lang.StringgetPassword()java.lang.StringgetScriptCharset()intgetTimeout()JQueryAjaxOption.AjaxTypegetType()java.lang.StringgetUrl()java.lang.StringgetUsername()booleanisAsync()booleanisCache()booleanisGlobal()booleanisIfModified()booleanisProcessData()JQueryAjaxOptionsetAsync(boolean async)By default, all requests are sent asynchronous (i.e.JQueryAjaxOptionsetBeforeSendEvent(JsScope beforeSend)A pre-callback to modify the XMLHttpRequest object before it is sent.JQueryAjaxOptionsetCache(boolean cache)Set to false it will force the pages that you request to not be cached by the browser.JQueryAjaxOptionsetCompleteEvent(JsScope complete)A function to be called when the request finishes (after success and error callbacks are executed).JQueryAjaxOptionsetContentType(java.lang.String contentType)When sending data to the server, use this content-type.JQueryAjaxOptionsetData(java.lang.String data)Data to be sent to the server.JQueryAjaxOptionsetDataFilterEvent(JsScope dataFilter)A function to be used to handle the raw responsed data of XMLHttpRequest.JQueryAjaxOptionsetDataType(java.lang.String dataType)The type of data that you're expecting back from the server.JQueryAjaxOptionsetErrorEvent(JsScope error)A function to be called if the request fails.JQueryAjaxOptionsetGlobal(boolean global)Whether to trigger global AJAX event handlers for this request.JQueryAjaxOptionsetIfModified(boolean ifModified)Allow the request to be successful only if the response has changed since the last request.JQueryAjaxOptionsetJsonp(java.lang.String jsonp)Override the callback function name in a jsonp request.voidsetObject(JQueryAjaxOption object)JQueryAjaxOptionsetPassword(java.lang.String password)A password to be used in response to an HTTP access authentication request.JQueryAjaxOptionsetProcessData(boolean processData)By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded".JQueryAjaxOptionsetScriptCharset(java.lang.String scriptCharset)Only for requests with 'jsonp' or 'script' dataType and GET type.JQueryAjaxOptionsetSuccessEvent(JsScope success)A function to be called if the request succeeds.JQueryAjaxOptionsetTimeout(int timeout)Set a local timeout (in milliseconds) for the request.JQueryAjaxOptionsetType(JQueryAjaxOption.AjaxType type)The type of request to make ("POST" or "GET"), default is "GET".JQueryAjaxOptionsetUrl(java.lang.String url)The URL to request.JQueryAjaxOptionsetUsername(java.lang.String username)A username to be used in response to an HTTP access authentication request.JQueryAjaxOptionsetXhrEvent(JsScope xhr)Callback for creating the XMLHttpRequest object.
-
-
-
Method Detail
-
getJavascriptOption
public java.lang.CharSequence getJavascriptOption()
Description copied from interface:IComplexOptionMethod retrieving the javascript representation of this complex option- Specified by:
getJavascriptOptionin interfaceIComplexOption- Returns:
- the javascript
-
getOptions
protected Options getOptions()
Method retrieving the options- Returns:
- the options
-
setAsync
public JQueryAjaxOption setAsync(boolean async)
By default, all requests are sent asynchronous (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.- Parameters:
async-
-
isAsync
public boolean isAsync()
- Returns:
- the async option value
-
setCache
public JQueryAjaxOption setCache(boolean cache)
Set to false it will force the pages that you request to not be cached by the browser.- Parameters:
cache-
-
isCache
public boolean isCache()
- Returns:
- the cache option value
-
setContentType
public JQueryAjaxOption setContentType(java.lang.String contentType)
When sending data to the server, use this content-type. Default is "application/x-www-form-urlencoded", which is fine for most cases.- Parameters:
contentType-
-
getContentType
public java.lang.String getContentType()
- Returns:
- the contentType option value
-
setData
public JQueryAjaxOption setData(java.lang.String data)
Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key i.e. {foo:["bar1", "bar2"]} becomes '&foo=bar1&foo=bar2'.- Parameters:
data-
-
getData
public java.lang.String getData()
- Returns:
- the contentType option value
-
setDataType
public JQueryAjaxOption setDataType(java.lang.String dataType)
The type of data that you're expecting back from the server. If none is specified, jQuery will intelligently pass either responseXML or responseText to your success callback, based on the MIME type of the response. The available types (and the result passed as the first argument to your success callback) are:- "xml": Returns a XML document that can be processed via jQuery.
- "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
- "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching unless option "cache" is used. Note: This will turn POSTs into GETs for remote-domain requests.
- "json": Evaluates the response as JSON and returns a JavaScript Object.
- "jsonp": Loads in a JSON block using JSONP. Will add an extra "?callback=?" to the end of your URL to specify the callback. (Added in jQuery 1.2)
- "text": A plain text string.
- Parameters:
dataType-
-
getDataType
public java.lang.String getDataType()
- Returns:
- the dataType option value
-
setGlobal
public JQueryAjaxOption setGlobal(boolean global)
Whether to trigger global AJAX event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events.- Parameters:
global-
-
isGlobal
public boolean isGlobal()
- Returns:
- the global option value
-
setIfModified
public JQueryAjaxOption setIfModified(boolean ifModified)
Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header.- Parameters:
ifModified-
-
isIfModified
public boolean isIfModified()
- Returns:
- the ifModified option value
-
setJsonp
public JQueryAjaxOption setJsonp(java.lang.String jsonp)
Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url for a GET or the data for a POST. So {jsonp:'onJsonPLoad'} would result in 'onJsonPLoad=?' passed to the server.- Parameters:
jsonp-
-
getJsonp
public java.lang.String getJsonp()
- Returns:
- the jsonp option value
-
setPassword
public JQueryAjaxOption setPassword(java.lang.String password)
A password to be used in response to an HTTP access authentication request.- Parameters:
password-
-
getPassword
public java.lang.String getPassword()
- Returns:
- the password option value
-
setProcessData
public JQueryAjaxOption setProcessData(boolean processData)
By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send DOMDocuments, or other non-processed data, set this option to false.- Parameters:
processData-
-
isProcessData
public boolean isProcessData()
- Returns:
- the processData option value
-
setScriptCharset
public JQueryAjaxOption setScriptCharset(java.lang.String scriptCharset)
Only for requests with 'jsonp' or 'script' dataType and GET type. Forces the request to be interpreted as a certain charset. Only needed for charset differences between the remote and local content.- Parameters:
scriptCharset-
-
getScriptCharset
public java.lang.String getScriptCharset()
- Returns:
- the scriptCharset option value
-
setTimeout
public JQueryAjaxOption setTimeout(int timeout)
Set a local timeout (in milliseconds) for the request. This will override the global timeout, if one is set via $.ajaxSetup. For example, you could use this property to give a single request a longer timeout than all other requests that you've set to time out in one second. See $.ajaxSetup() for global timeouts.- Parameters:
timeout-
-
getTimeout
public int getTimeout()
- Returns:
- the timeout option value
-
setType
public JQueryAjaxOption setType(JQueryAjaxOption.AjaxType type)
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.- Parameters:
type-
-
getType
public JQueryAjaxOption.AjaxType getType()
- Returns:
- the type option value
-
setUrl
public JQueryAjaxOption setUrl(java.lang.String url)
The URL to request. This *must* be a string (e.g., document.location.href) and not a Location object (e.g., document.location)- Parameters:
url-
-
getUrl
public java.lang.String getUrl()
- Returns:
- the url option value
-
setUsername
public JQueryAjaxOption setUsername(java.lang.String username)
A username to be used in response to an HTTP access authentication request.- Parameters:
username-
-
getUsername
public java.lang.String getUsername()
- Returns:
- the username option value
-
setBeforeSendEvent
public JQueryAjaxOption setBeforeSendEvent(JsScope beforeSend)
A pre-callback to modify the XMLHttpRequest object before it is sent. Use this to set custom headers etc. The XMLHttpRequest is passed as the only argument. This is an Ajax Event. You may return false in function to cancel the request.- Parameters:
beforeSend-
-
setCompleteEvent
public JQueryAjaxOption setCompleteEvent(JsScope complete)
A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The XMLHttpRequest object and a string describing the type of success of the request- Parameters:
complete-
-
setDataFilterEvent
public JQueryAjaxOption setDataFilterEvent(JsScope dataFilter)
A function to be used to handle the raw responsed data of XMLHttpRequest. This is a pre-filtering function to sanitize the response.You should return the sanitized data.The function gets passed two arguments: The raw data returned from the server, and the 'dataType' parameter.- Parameters:
dataFilter-
-
setErrorEvent
public JQueryAjaxOption setErrorEvent(JsScope error)
A function to be called if the request fails. The function is passed three arguments: The XMLHttpRequest object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "notmodified" and "parsererror"- Parameters:
error-
-
setSuccessEvent
public JQueryAjaxOption setSuccessEvent(JsScope success)
A function to be called if the request succeeds. The function gets passed two arguments: The data returned from the server, formatted according to the 'dataType' parameter, and a string describing the status. This is an Ajax Event.- Parameters:
success-
-
setXhrEvent
public JQueryAjaxOption setXhrEvent(JsScope xhr)
Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory.It's not available in jQuery 1.2.6 and in any early version.- Parameters:
xhr-
-
getObject
public JQueryAjaxOption getObject()
- Specified by:
getObjectin interfaceorg.apache.wicket.model.IModel<JQueryAjaxOption>
-
setObject
public void setObject(JQueryAjaxOption object)
- Specified by:
setObjectin interfaceorg.apache.wicket.model.IModel<JQueryAjaxOption>
-
detach
public void detach()
- Specified by:
detachin interfaceorg.apache.wicket.model.IDetachable- Specified by:
detachin interfaceorg.apache.wicket.model.IModel<JQueryAjaxOption>
-
-