Class FormComponentUpdatingBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.markup.html.form.FormComponentUpdatingBehavior
-
- All Implemented Interfaces:
java.io.Serializable,IComponentAwareEventSink,IRequestListener,IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable
public class FormComponentUpdatingBehavior extends Behavior implements IRequestListener
A behavior to get notifications when aFormComponentchanges its value.Contrary to
AjaxFormComponentUpdatingBehaviorall notification are sent via standard HTTP requests and the full page is rendered as a response.Notification is triggered by an event suitable for the host component this behavior is added to - if needed
getEvent()can be overridden to change the default ( forDropDownChoice,ListMultipleChoiceandAbstractTextComponent, for anything else).Note: This behavior has limited support for
FormComponents outside of a form, i.e. multiple choice components (ListMultipleChoiceandRadioGroup) will send their last selected choice only.- See Also:
onUpdate(), Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FormComponentUpdatingBehavior()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(Component component)Bind this handler to the given component.protected java.lang.StringgetEvent()Which JavaScript event triggers notification.FormComponent<?>getFormComponent()Get the hosting component.booleangetStatelessHint(Component component)This method returns false if the behavior generates a callback url (for example ajax behaviors)protected booleangetUpdateModel()Gives the control to the application to decide whether the form component model should be updated automatically or not.protected voidonBind()Called when the component was bound to it's host component.voidonComponentTag(Component component, ComponentTag tag)Called any time a component that has this behavior registered is rendering the component tag.protected voidonError(java.lang.RuntimeException e)Hook method invoked when updating of the component resulted in an error.voidonRequest()Called when a request is received.protected voidonUpdate()Hook method invoked when the component is updated.-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, canCallListener, detach, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag, renderHead, unbind
-
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
-
-
-
-
Method Detail
-
getStatelessHint
public boolean getStatelessHint(Component component)
Description copied from class:BehaviorThis method returns false if the behavior generates a callback url (for example ajax behaviors)- Overrides:
getStatelessHintin classBehavior- Parameters:
component- the component that has this behavior coupled.- Returns:
- boolean true or false.
-
bind
public final void bind(Component component)
Description copied from class:BehaviorBind this handler to the given component. This method is called by the host component immediately after this behavior is added to it. This method is useful if you need to do initialization based on the component it is attached and you can't wait to do it at render time. Keep in mind that if you decide to keep a reference to the host component, it is not thread safe anymore, and should thus only be used in situations where you do not reuse the behavior for multiple components.
-
onBind
protected void onBind()
Called when the component was bound to it's host component. You can get the bound host component by callinggetFormComponent().
-
getFormComponent
public final FormComponent<?> getFormComponent()
Get the hosting component.- Returns:
- hosting component
-
onComponentTag
public void onComponentTag(Component component, ComponentTag tag)
Description copied from class:BehaviorCalled any time a component that has this behavior registered is rendering the component tag.- Overrides:
onComponentTagin classBehavior- Parameters:
component- the component that renders this tag currentlytag- the tag that is rendered
-
getEvent
protected java.lang.String getEvent()
Which JavaScript event triggers notification.- Returns:
- or , depending on the host component
-
getUpdateModel
protected boolean getUpdateModel()
Gives the control to the application to decide whether the form component model should be updated automatically or not. Make sure to callFormComponent.valid()additionally in case the application want to update the model manually.- Returns:
- true if the model of form component should be updated, false otherwise
-
onUpdate
protected void onUpdate()
Hook method invoked when the component is updated.Note:
#onError(AjaxRequestTarget, RuntimeException)is called instead when processing of theFormComponentfailed with conversion or validation errors!
-
onError
protected void onError(java.lang.RuntimeException e)
Hook method invoked when updating of the component resulted in an error.The
RuntimeExceptionwill be null if it was just a validation or conversion error of the FormComponent.- Parameters:
e- optional runtime exception
-
onRequest
public final void onRequest()
Description copied from interface:IRequestListenerCalled when a request is received.- Specified by:
onRequestin interfaceIRequestListener
-
-