org.apache.wicket.ajax.form
Class AjaxFormComponentUpdatingBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.behavior.AbstractAjaxBehavior
          extended by org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
              extended by org.apache.wicket.ajax.AjaxEventBehavior
                  extended by org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior
All Implemented Interfaces:
Serializable, IBehaviorListener, IComponentAwareEventSink, IRequestListener, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
AjaxFormChoiceComponentUpdatingBehavior, OnChangeAjaxBehavior

public abstract class AjaxFormComponentUpdatingBehavior
extends AjaxEventBehavior

A behavior that updates the hosting FormComponent via ajax when an event it is attached to is triggered. This behavior encapsulates the entire form-processing workflow as relevant only to this component so if validation is successful the component's model will be updated according to the submitted value.

NOTE: This behavior does not validate any IFormValidators attached to this form even though they may reference the component being updated.

NOTE: This behavior does not work on Choices or Groups use the AjaxFormChoiceComponentUpdatingBehavior for that.

Since:
1.2
Author:
Igor Vaynberg (ivaynberg)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
 
Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener
INTERFACE
 
Constructor Summary
AjaxFormComponentUpdatingBehavior(String event)
          Construct.
 
Method Summary
protected  void checkComponent(FormComponent<?> component)
          Check the component this behavior is bound to.
protected  boolean disableFocusOnBlur()
          Determines whether the focus will not be restored when the event is blur.
protected  FormComponent<?> getFormComponent()
           
protected  boolean getUpdateModel()
           
protected  void onBind()
          Subclasses should call super.onBind()
protected  void onError(AjaxRequestTarget target, RuntimeException e)
          Called to handle any error resulting from updating form component.
protected  void onEvent(AjaxRequestTarget target)
          Listener method for the ajax event
protected abstract  void onUpdate(AjaxRequestTarget target)
          Listener invoked on the ajax request.
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, onCheckEvent, renderHead, respond
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, getChannel, getFailureScript, getPreconditionScript, getSuccessScript, 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, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onConfigure, onEvent, onException, onRemove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxFormComponentUpdatingBehavior

public AjaxFormComponentUpdatingBehavior(String event)
Construct.

Parameters:
event - event to trigger this behavior
Method Detail

onBind

protected void onBind()
Description copied from class: AbstractDefaultAjaxBehavior
Subclasses should call super.onBind()

Overrides:
onBind in class AbstractDefaultAjaxBehavior
See Also:
AbstractAjaxBehavior.onBind()

checkComponent

protected void checkComponent(FormComponent<?> component)
Check the component this behavior is bound to.

Logs a warning in development mode when an AjaxFormChoiceComponentUpdatingBehavior should be used.

Parameters:
component - bound component

getFormComponent

protected final FormComponent<?> getFormComponent()
Returns:
FormComponent

updateAjaxAttributes

protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
Description copied from class: AbstractDefaultAjaxBehavior
Gives a chance to the specializations to modify the attributes.

Overrides:
updateAjaxAttributes in class AjaxEventBehavior

onEvent

protected final void onEvent(AjaxRequestTarget target)
Description copied from class: AjaxEventBehavior
Listener method for the ajax event

Specified by:
onEvent in class AjaxEventBehavior
Parameters:
target - the current request handler
See Also:
AjaxEventBehavior.onEvent(org.apache.wicket.ajax.AjaxRequestTarget)

getUpdateModel

protected boolean getUpdateModel()
Returns:
true if the model of form component should be updated, false otherwise

disableFocusOnBlur

protected boolean disableFocusOnBlur()
Determines whether the focus will not be restored when the event is blur. By default this is true, as we don't want to re-focus component on blur event.

Returns:
true if refocusing should be disabled, false otherwise

onUpdate

protected abstract void onUpdate(AjaxRequestTarget target)
Listener invoked on the ajax request. This listener is invoked after the component's model has been updated.

Parameters:
target - the current request handler

onError

protected void onError(AjaxRequestTarget target,
                       RuntimeException e)
Called to handle any error resulting from updating form component. Errors thrown from onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) will not be caught here. The RuntimeException will be null if it was just a validation or conversion error of the FormComponent

Parameters:
target - the current request handler
e - the error that occurred during the update of the component


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.