org.wicketstuff.jquery.validation
Class AjaxFormComponentValidatorBehaviour
java.lang.Object
org.apache.wicket.behavior.AbstractBehavior
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, org.apache.wicket.behavior.IBehavior, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.behavior.IComponentConfigurationBehavior, org.apache.wicket.IClusterable, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IHeaderContributor
public class AjaxFormComponentValidatorBehaviour
- extends org.apache.wicket.ajax.form.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
| Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior |
INDICATOR |
| Fields inherited from interface org.apache.wicket.behavior.IBehaviorListener |
INTERFACE |
|
Method Summary |
protected String |
getErrorJavascript()
Returns the javascript that will manipulate the markup to
show the error message. |
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. |
protected String |
getRemovePreviousErrorsScript()
Javascript used to remove previously shown error messages. |
protected void |
onError(org.apache.wicket.ajax.AjaxRequestTarget target,
RuntimeException e)
Adds the error-javascript to the response since the component
has errors. |
protected void |
onUpdate(org.apache.wicket.ajax.AjaxRequestTarget target)
When the component renders, onUpdate will remove the
markup containing any previous error-message. |
void |
renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
Add the JQuery library so we can use it in the onError method
to manipulate the markup. |
| Methods inherited from class org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior |
disableFocusOnBlur, getEventHandler, getFormComponent, getUpdateModel, onBind, onCheckEvent, onEvent |
| Methods inherited from class org.apache.wicket.ajax.AjaxEventBehavior |
generateCallbackScript, getEvent, onComponentTag, respond, setThrottleDelay |
| Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior |
findIndicatorId, getAjaxCallDecorator, getCallbackScript, getCallbackScript, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onRequest, throttleScript |
| Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior |
bind, getCallbackUrl, getCallbackUrl, getComponent, getImplementationId, getStatelessHint, onComponentRendered, onComponentTag, onRendered, onRenderHeadContribution, onRenderHeadInitContribution |
| Methods inherited from class org.apache.wicket.behavior.AbstractBehavior |
afterRender, beforeRender, cleanup, detach, detachModel, exception, isEnabled, isTemporary, onConfigure, onException, rendered |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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(org.apache.wicket.ajax.AjaxRequestTarget target)
- When the component renders, onUpdate will remove the
markup containing any previous error-message.
- Specified by:
onUpdate in class org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior
- Parameters:
target -
getRemovePreviousErrorsScript
protected String getRemovePreviousErrorsScript()
- Javascript used to remove previously shown error messages.
- Returns:
onError
protected void onError(org.apache.wicket.ajax.AjaxRequestTarget target,
RuntimeException e)
- Adds the error-javascript to the response since the component
has errors.
- Overrides:
onError in class org.apache.wicket.ajax.form.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(org.apache.wicket.markup.html.IHeaderResponse response)
- Add the JQuery library so we can use it in the onError method
to manipulate the markup.
- Specified by:
renderHead in interface org.apache.wicket.markup.html.IHeaderContributor- Overrides:
renderHead in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
- Parameters:
response -
Copyright © 2012. All Rights Reserved.