Package org.apache.wicket.ajax.form
Class AjaxFormSubmitBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.behavior.AbstractAjaxBehavior
-
- org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
- org.apache.wicket.ajax.AjaxEventBehavior
-
- org.apache.wicket.ajax.form.AjaxFormSubmitBehavior
-
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IRequestListener
,IComponentAwareHeaderContributor
,IClusterable
public abstract class AjaxFormSubmitBehavior extends AjaxEventBehavior
Ajax event behavior that submits a form via ajax when the event it is attached to, is invoked.The form must have an id attribute in the markup or have MarkupIdSetter added.
- Since:
- 1.2
- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
AjaxEventBehavior
,onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
,onAfterSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
,onError(org.apache.wicket.ajax.AjaxRequestTarget)
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AjaxFormSubmitBehavior.AjaxFormSubmitter
A publicly reachable class that allows to introspect the submitter, e.g.
-
Field Summary
-
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
-
-
Constructor Summary
Constructors Constructor Description AjaxFormSubmitBehavior(String event)
Constructor.AjaxFormSubmitBehavior(Form<?> form, String event)
Construct.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Form<?>
findForm()
Finds form that will be submittedboolean
getDefaultProcessing()
Form<?>
getForm()
protected void
onAfterSubmit(AjaxRequestTarget target)
Override this method to provide special submit handling in a multi-button form.protected void
onError(AjaxRequestTarget target)
Listener method invoked when the form has been processed and errors occurredprotected void
onEvent(AjaxRequestTarget target)
Listener method for the ajax eventstatic AjaxFormSubmitBehavior
onSubmit(String eventName, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onSubmit)
Creates anAjaxFormSubmitBehavior
based on lambda expressionsprotected void
onSubmit(AjaxRequestTarget target)
Override this method to provide special submit handling in a multi-button form.void
setDefaultProcessing(boolean defaultProcessing)
protected boolean
shouldTriggerJavaScriptSubmitEvent()
Controls whether or not a JSsubmit
should be triggered on the submitting form.protected void
updateAjaxAttributes(AjaxRequestAttributes attributes)
Gives a chance to the specializations to modify the attributes.-
Methods inherited from class org.apache.wicket.ajax.AjaxEventBehavior
getEvent, onEvent, renderHead, respond
-
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
-
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
-
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IRequestListener
rendersPage
-
-
-
-
Constructor Detail
-
AjaxFormSubmitBehavior
public AjaxFormSubmitBehavior(String event)
Constructor. This constructor can only be used when the component this behavior is attached to is inside a form.- Parameters:
event
- javascript event this behavior is attached to, like onclick
-
AjaxFormSubmitBehavior
public AjaxFormSubmitBehavior(Form<?> form, String event)
Construct.- Parameters:
form
- form that will be submittedevent
- javascript event this behavior is attached to, like onclick
-
-
Method Detail
-
findForm
protected Form<?> findForm()
Finds form that will be submitted- Returns:
- form to submit or
null
if none found
-
shouldTriggerJavaScriptSubmitEvent
protected boolean shouldTriggerJavaScriptSubmitEvent()
Controls whether or not a JSsubmit
should be triggered on the submitting form. False by default.- Returns:
- true if
submit
should be triggered, false otherwise
-
updateAjaxAttributes
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
Description copied from class:AbstractDefaultAjaxBehavior
Gives a chance to the specializations to modify the attributes.- Overrides:
updateAjaxAttributes
in classAjaxEventBehavior
-
onEvent
protected void onEvent(AjaxRequestTarget target)
Description copied from class:AjaxEventBehavior
Listener method for the ajax event- Specified by:
onEvent
in classAjaxEventBehavior
- Parameters:
target
- the current request handler
-
onAfterSubmit
protected void onAfterSubmit(AjaxRequestTarget target)
Override this method to provide special submit handling in a multi-button form. This method will be called after the form's onSubmit method.- Parameters:
target
- theAjaxRequestTarget
-
onSubmit
protected void onSubmit(AjaxRequestTarget target)
Override this method to provide special submit handling in a multi-button form. This method will be called before the form's onSubmit method.- Parameters:
target
- theAjaxRequestTarget
-
onError
protected void onError(AjaxRequestTarget target)
Listener method invoked when the form has been processed and errors occurred- Parameters:
target
-
-
getDefaultProcessing
public boolean getDefaultProcessing()
- Returns:
true
for default processing- See Also:
Button.getDefaultFormProcessing()
-
setDefaultProcessing
public void setDefaultProcessing(boolean defaultProcessing)
- Parameters:
defaultProcessing
-- See Also:
Button.setDefaultFormProcessing(boolean)
-
onSubmit
public static AjaxFormSubmitBehavior onSubmit(String eventName, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onSubmit)
Creates anAjaxFormSubmitBehavior
based on lambda expressions- Parameters:
eventName
- the event nameonSubmit
- theSerializableConsumer
which accepts theAjaxRequestTarget
- Returns:
- the
AjaxFormSubmitBehavior
-
-