Class AjaxRequestAttributes
- java.lang.Object
-
- org.apache.wicket.ajax.attributes.AjaxRequestAttributes
-
public final class AjaxRequestAttributes extends java.lang.ObjectAttributes of an Ajax Request.- Author:
- Matej Knopp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAjaxRequestAttributes.EventPropagationThe JavaScript event propagation typestatic classAjaxRequestAttributes.MethodThe method to be used when submitting a form
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringXML_DATA_TYPE
-
Constructor Summary
Constructors Constructor Description AjaxRequestAttributes()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<IAjaxCallListener>getAjaxCallListeners()AjaxChannelgetChannel()java.lang.CharSequencegetChildSelector()java.lang.StringgetDataType()Returns the type of the data in the Ajax response.java.util.List<java.lang.CharSequence>getDynamicExtraParameters()Array of JavaScript functions that produce additional URL arguments.java.lang.String[]getEventNames()AjaxRequestAttributes.EventPropagationgetEventPropagation()Only applies for event behaviors.java.util.Map<java.lang.String,java.lang.Object>getExtraParameters()Map that contains additional (static) URL parameters.java.lang.StringgetFormId()AjaxRequestAttributes.MethodgetMethod()Returns the type of the Ajax request:GETorPOST.org.apache.wicket.util.time.DurationgetRequestTimeout()Returns the timeout in milliseconds for the AJAX request.java.lang.StringgetSubmittingComponentName()ThrottlingSettingsgetThrottlingSettings()booleanisAsynchronous()booleanisMultipart()Returns whether the form submit is multipart.booleanisPreventDefault()Only applies for event behaviors.booleanisSerializeRecursively()booleanisWicketAjaxResponse()AjaxRequestAttributessetAsynchronous(boolean async)AjaxRequestAttributessetChannel(AjaxChannel channel)voidsetChildSelector(java.lang.CharSequence childSelector)AjaxRequestAttributessetDataType(java.lang.String dataType)AjaxRequestAttributessetEventNames(java.lang.String... eventNames)AjaxRequestAttributessetEventPropagation(AjaxRequestAttributes.EventPropagation eventPropagation)Only applies to event behaviors.AjaxRequestAttributessetFormId(java.lang.String formId)AjaxRequestAttributessetMethod(AjaxRequestAttributes.Method method)Sets the type of the Ajax request:GETorPOST.AjaxRequestAttributessetMultipart(boolean multipart)Determines whether the form submit is multipart.AjaxRequestAttributessetPreventDefault(boolean preventDefault)Only applies for event behaviors.AjaxRequestAttributessetRequestTimeout(org.apache.wicket.util.time.Duration requestTimeout)Sets the timeout in milliseconds for the AJAX request.AjaxRequestAttributessetSerializeRecursively(boolean serializeRecursively)AjaxRequestAttributessetSubmittingComponentName(java.lang.String submittingComponentName)AjaxRequestAttributessetThrottlingSettings(ThrottlingSettings throttlingSettings)AjaxRequestAttributessetWicketAjaxResponse(boolean wicketAjaxResponse)
-
-
-
Field Detail
-
XML_DATA_TYPE
public static final java.lang.String XML_DATA_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getChildSelector
public java.lang.CharSequence getChildSelector()
- Returns:
- The selector string that filters the descendants
- See Also:
childSelector
-
setChildSelector
public void setChildSelector(java.lang.CharSequence childSelector)
- Parameters:
childSelector- The selector string that filters the descendants- See Also:
childSelector
-
isMultipart
public boolean isMultipart()
Returns whether the form submit is multipart.Note that for multipart AJAX requests a hidden IFRAME will be used and that can have negative impact on error detection.
- Returns:
trueif the form submit should be multipart,falseotherwise
-
setMultipart
public AjaxRequestAttributes setMultipart(boolean multipart)
Determines whether the form submit is multipart.Note that for multipart AJAX requests a hidden IFRAME will be used and that can have negative impact on error detection.
- Parameters:
multipart-- Returns:
- this object
-
getMethod
public AjaxRequestAttributes.Method getMethod()
Returns the type of the Ajax request:GETorPOST.For a
POSTrequest all URL arguments are submitted as body. This can be useful if the URL parameters are longer than maximal URL length.- Returns:
- the type of the Ajax request. Default: AjaxRequestAttributes.Method.GET
-
setMethod
public AjaxRequestAttributes setMethod(AjaxRequestAttributes.Method method)
Sets the type of the Ajax request:GETorPOST.For a
POSTrequest all URL arguments are submitted as body. This can be useful if the URL parameters are longer than maximal URL length.- Parameters:
method- the type of the Ajax request- Returns:
thisobject for chaining
-
getRequestTimeout
public org.apache.wicket.util.time.Duration getRequestTimeout()
Returns the timeout in milliseconds for the AJAX request. This only involves the actual communication and not the processing afterwards. Can benullin which case the default request timeout will be used.- Returns:
- request timeout or
nullfor default timeout. Default: no timeout.
-
setRequestTimeout
public AjaxRequestAttributes setRequestTimeout(org.apache.wicket.util.time.Duration requestTimeout)
Sets the timeout in milliseconds for the AJAX request. This only involves the actual communication and not the processing afterwards. Can benullin which case the default request timeout will be used.- Parameters:
requestTimeout-- Returns:
- this object
-
getAjaxCallListeners
public java.util.List<IAjaxCallListener> getAjaxCallListeners()
- Returns:
- a list of
IAjaxCallListeners which will be notified during the the execution of the Ajax call.
-
getExtraParameters
public java.util.Map<java.lang.String,java.lang.Object> getExtraParameters()
Map that contains additional (static) URL parameters. These will be appended to the request URL. If you need more than one value for a key then use a java.util.List or an Object[] as a value of that key.- Returns:
- a map with additional URL arguments
- See Also:
getDynamicExtraParameters()
-
getDynamicExtraParameters
public java.util.List<java.lang.CharSequence> getDynamicExtraParameters()
Array of JavaScript functions that produce additional URL arguments.If there are no multivalued parameters then the function can return a simple JavaScript object. Example:
return { 'param1': document.body.tagName, 'param2': calculateParam2() }If there are multivalued parameters then an array of objects may be used. Example:
return [ { name: 'param1', value: document.body.tagName }, { name: 'param1', value: calculateSecondValueForParam1() }, { name: 'param2', value: calculateParam2() } ]- Returns:
- a list of functions that produce additional URL arguments.
- See Also:
getExtraParameters()
-
isPreventDefault
public boolean isPreventDefault()
Only applies for event behaviors. Returns whether the behavior should prevent the default event handler to be invoked. For example if the behavior is attached to a link and isPreventDefault() returnstrue, the link's URL will not be followed. If the Ajax behavior is attached to a checkbox or a radio button then the default behavior should be allowed to actually check the box or radio button, i.e. this method should returnfalse.- Returns:
falseif the default event handler should be invoked
-
setPreventDefault
public AjaxRequestAttributes setPreventDefault(boolean preventDefault)
Only applies for event behaviors. Determines whether the behavior should prevent the default event handler to be invoked.- Parameters:
preventDefault-- Returns:
thisobject for chaining- See Also:
isPreventDefault(),isPreventDefault()
-
getEventPropagation
public AjaxRequestAttributes.EventPropagation getEventPropagation()
Only applies for event behaviors. Returns whether the behavior should allow the JavaScript event to propagate to the parent of its target.
-
setEventPropagation
public AjaxRequestAttributes setEventPropagation(AjaxRequestAttributes.EventPropagation eventPropagation)
Only applies to event behaviors. Determines whether the behavior should allow the JavaScript event to propagate to the parent of its target.- Parameters:
eventPropagation- the type of the stop- Returns:
thisobject, for chaining
-
setAsynchronous
public AjaxRequestAttributes setAsynchronous(boolean async)
- Parameters:
async- a flag whether to do asynchronous Ajax call or not- Returns:
thisobject for chaining
-
isAsynchronous
public boolean isAsynchronous()
- Returns:
- whether to do asynchronous Ajax call
-
getChannel
public AjaxChannel getChannel()
- Returns:
- the channel to use
-
setChannel
public AjaxRequestAttributes setChannel(AjaxChannel channel)
- Parameters:
channel- the Ajax channel to use. Passnullto use the default channel with name 0 and queueing type.- Returns:
thisobject for chaining
-
getEventNames
public java.lang.String[] getEventNames()
- Returns:
- the name(s) of the event(s) which will trigger the Ajax call
-
setEventNames
public AjaxRequestAttributes setEventNames(java.lang.String... eventNames)
- Parameters:
eventNames- the names of the events which will trigger the Ajax call- Returns:
thisobject for chaining
-
getFormId
public java.lang.String getFormId()
- Returns:
- the id of the for that should be submitted
-
setFormId
public AjaxRequestAttributes setFormId(java.lang.String formId)
- Parameters:
formId- the id of the for that should be submitted- Returns:
thisobject for chaining
-
getSubmittingComponentName
public java.lang.String getSubmittingComponentName()
- Returns:
- the input name of the button/link that submits the form
-
setSubmittingComponentName
public AjaxRequestAttributes setSubmittingComponentName(java.lang.String submittingComponentName)
- Parameters:
submittingComponentName- the input name of the button/link that submits the form- Returns:
thisobject for chaining
-
isWicketAjaxResponse
public boolean isWicketAjaxResponse()
- Returns:
- a flag indicating whether the Ajax response should be processed by Wicket (i.e. to
replace components, execute scripts, etc.). Default:
true.
-
setWicketAjaxResponse
public AjaxRequestAttributes setWicketAjaxResponse(boolean wicketAjaxResponse)
- Parameters:
wicketAjaxResponse- a flag indicating whether the Ajax response should be processed by Wicket (i.e. to replace components, execute scripts, etc.).- Returns:
thisobject for chaining
-
getDataType
public java.lang.String getDataType()
Returns the type of the data in the Ajax response. For example: 'xml', 'json', 'html', etc. See the documentation of jQuery.ajax() method for more information.- Returns:
- the type of the data in the Ajax response.
-
setDataType
public AjaxRequestAttributes setDataType(java.lang.String dataType)
- Parameters:
dataType- the type of the data in the Ajax response.- Returns:
thisobject for chaining
-
getThrottlingSettings
public ThrottlingSettings getThrottlingSettings()
- Returns:
- the settings to use when throttling is needed.
-
setThrottlingSettings
public AjaxRequestAttributes setThrottlingSettings(ThrottlingSettings throttlingSettings)
- Parameters:
throttlingSettings- the settings to use when throttling is needed. Passnullto disable throttling.- Returns:
thisobject for chaining
-
isSerializeRecursively
public boolean isSerializeRecursively()
- Returns:
- whether to collect (submit) the name/value pairs for all HTML form elements children of the HTML element with the JavaScript listener
-
setSerializeRecursively
public AjaxRequestAttributes setSerializeRecursively(boolean serializeRecursively)
- Parameters:
serializeRecursively- a flag indicating whether to collect (submit) the name/value pairs for all HTML form elements children of the HTML element with the JavaScript listener
-
-