com.alogient.cameleon.extension.wicket.ui.form.component
Class AjaxValidationStyleBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      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
                      extended by com.alogient.cameleon.extension.wicket.ui.form.component.AjaxValidationStyleBehavior
All Implemented Interfaces:
Serializable, org.apache.wicket.behavior.IBehavior, org.apache.wicket.behavior.IBehaviorListener, org.apache.wicket.IClusterable, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.IHeaderContributor

public class AjaxValidationStyleBehavior
extends org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior

Behavior that checks if a FormComponent is valid. Valid FormComponent objects get the CSS class 'formcomponent valid' and invalid FormComponent objects get the CSS class 'formcomponent invalid'. See AjaxFormComponentUpdatingBehavior for more details over the parent class. You can use this code under Apache 2.0 license, as long as you retain the copyright messages. Tested with Wicket 1.3.4

Author:
Daan, StuQ.nl
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
AjaxValidationStyleBehavior(String event, org.apache.wicket.Component updateComponent)
          Constructor.
AjaxValidationStyleBehavior(String event, org.apache.wicket.Component updateComponent, String errorClass)
          Constructor.
 
Method Summary
 void onComponentTag(org.apache.wicket.markup.ComponentTag tag)
          
protected  void onError(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget, RuntimeException e)
          Listener invoked on the ajax request.
protected  void onUpdate(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Listener invoked on the ajax request.
 
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, respond, setThrottleDelay
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAjaxCallDecorator, getCallbackScript, getCallbackScript, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onRequest, renderHead, 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, onException, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxValidationStyleBehavior

public AjaxValidationStyleBehavior(String event,
                                   org.apache.wicket.Component updateComponent)
Constructor.

Parameters:
event - of type String (for example 'onblur', 'onkeyup', etc.)
updateComponent - is the Component that must be updated (for example the FeedbackLabel containing the error message for this FormComponent)

AjaxValidationStyleBehavior

public AjaxValidationStyleBehavior(String event,
                                   org.apache.wicket.Component updateComponent,
                                   String errorClass)
Constructor.

Parameters:
event - of type String (for example 'onblur', 'onkeyup', etc.)
updateComponent - is the Component that must be updated (for example the FeedbackLabel containing the error message for this FormComponent)
errorClass - the error class to set
Method Detail

onError

protected void onError(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget,
                       RuntimeException e)
Listener invoked on the ajax request. This listener is invoked after the Component's model has been updated. Handles the change of a css class when an error has occurred.

Overrides:
onError in class org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior
Parameters:
ajaxRequestTarget - of type AjaxRequestTarget
e - of type RuntimeException

onUpdate

protected void onUpdate(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Listener invoked on the ajax request. This listener is invoked after the Component's model has been updated. Handles the change of a css class when validation was succesful.

Specified by:
onUpdate in class org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior
Parameters:
ajaxRequestTarget - of type AjaxRequestTarget

onComponentTag

public void onComponentTag(org.apache.wicket.markup.ComponentTag tag)

Overrides:
onComponentTag in class org.apache.wicket.ajax.AjaxEventBehavior


Copyright © 2011 Alogient. All Rights Reserved.