org.wicketstuff.jquery.validation
Class AjaxFormComponentValidatorBehaviour
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.AjaxFormComponentUpdatingBehavior
org.wicketstuff.jquery.validation.AjaxFormComponentValidatorBehaviour
- All Implemented Interfaces:
- Serializable, IBehaviorListener, IClusterable, IComponentAwareEventSink, IRequestListener, IComponentAwareHeaderContributor
public class AjaxFormComponentValidatorBehaviour
- extends AjaxFormComponentUpdatingBehavior
Ajax validation behaviour that triggers when the selected event is fired. The default action is
to add a css class to the parent element of the component and add any error messages in a span
directly after the component. You can change this behaviour by overriding getErrorJavascript().
By default it uses JQuery to do the markup manipulation. You can either skip jquery or load
another library by overriding the renderHead method.
This behaviour will also update the model object when the selected client side event fires.
- Author:
- Edvin Syse
- See Also:
- Serialized Form
ERROR_COMPONENT_CLASS
public static final String ERROR_COMPONENT_CLASS
- See Also:
- Constant Field Values
ERROR_MESSAGE_CLASS
public static final String ERROR_MESSAGE_CLASS
- See Also:
- Constant Field Values
AjaxFormComponentValidatorBehaviour
public AjaxFormComponentValidatorBehaviour()
AjaxFormComponentValidatorBehaviour
public AjaxFormComponentValidatorBehaviour(String event)
onUpdate
protected void onUpdate(AjaxRequestTarget target)
- When the component renders, onUpdate will remove the markup containing any previous
error-message.
- Specified by:
onUpdate in class AjaxFormComponentUpdatingBehavior
- Parameters:
target -
getRemovePreviousErrorsScript
protected String getRemovePreviousErrorsScript()
- Javascript used to remove previously shown error messages.
- Returns:
onError
protected void onError(AjaxRequestTarget target,
RuntimeException e)
- Adds the error-javascript to the response since the component has errors.
- Overrides:
onError in class AjaxFormComponentUpdatingBehavior
- Parameters:
target - The AjaxRequestTarget you can add components toe - The exception if any
getErrorJavascript
protected String getErrorJavascript()
- Returns the javascript that will manipulate the markup to show the error message. Defaults to
adding a CSS-class to the parent element (nice if you add a
or
around your label/component)
- Returns:
getErrorSeparator
protected String getErrorSeparator()
- The error separator is used to differentiate each error-message in case a component has more
than one error message
Defaults to separating using a
tag.
- Returns:
- the markup for separating multiple error message
renderHead
public void renderHead(Component component,
IHeaderResponse response)
- Add the JQuery library so we can use it in the onError method to manipulate the markup.
- Specified by:
renderHead in interface IComponentAwareHeaderContributor- Overrides:
renderHead in class AbstractDefaultAjaxBehavior
- Parameters:
response -
Copyright © 2013. All Rights Reserved.