org.apache.wicket.ajax
Class AjaxEventBehavior

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
All Implemented Interfaces:
Serializable, IBehaviorListener, IComponentAwareEventSink, IRequestListener, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
AjaxEditableLabel.LabelAjaxBehavior, AjaxFormComponentUpdatingBehavior, AjaxFormSubmitBehavior, AjaxPagingNavigationBehavior

public abstract class AjaxEventBehavior
extends AbstractDefaultAjaxBehavior

An ajax behavior that is attached to a certain client-side (usually javascript) event, such as click, change, keydown, etc.

Example:

         WebMarkupContainer div=new WebMarkupContainer(...);
         div.setOutputMarkupId(true);
         div.add(new AjaxEventBehavior("click") {
             protected void onEvent(AjaxRequestTarget target) {
                 System.out.println("ajax here!");
             }
         }
 
This behavior will be linked to the click javascript event of the div WebMarkupContainer represents, and so anytime a user clicks this div the onEvent(AjaxRequestTarget) of the behavior is invoked.

Note: getEvent() method cuts any on prefix from the given event name(s). This is being done for easier migration of applications coming from Wicket 1.5.x where Wicket used inline attributes like 'onclick=...'. If the application needs to use custom events with names starting with on then getEvent() should be overridden.

Since:
1.2
Author:
Igor Vaynberg (ivaynberg)
See Also:
onEvent(AjaxRequestTarget), 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
AjaxEventBehavior(String event)
          Construct.
 
Method Summary
 String getEvent()
           
protected  void onCheckEvent(String event)
           
protected abstract  void onEvent(AjaxRequestTarget target)
          Listener method for the ajax event
 void renderHead(Component component, IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
protected  void respond(AjaxRequestTarget target)
           
protected  void updateAjaxAttributes(AjaxRequestAttributes attributes)
          Gives a chance to the specializations to modify the attributes.
 
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, getChannel, getFailureScript, getPreconditionScript, getSuccessScript, onBind, 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

AjaxEventBehavior

public AjaxEventBehavior(String event)
Construct.

Parameters:
event - the event this behavior will be attached to
Method Detail

renderHead

public void renderHead(Component component,
                       IHeaderResponse response)
Description copied from class: Behavior
Render to the web response whatever the component wants to contribute to the head section.

Specified by:
renderHead in interface IComponentAwareHeaderContributor
Overrides:
renderHead in class AbstractDefaultAjaxBehavior
Parameters:
component - component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interface
response - Response object
See Also:
Behavior.renderHead(Component, org.apache.wicket.markup.head.IHeaderResponse)

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 AbstractDefaultAjaxBehavior

onCheckEvent

protected void onCheckEvent(String event)
Parameters:
event - the event this behavior will be attached to

getEvent

public String getEvent()
Returns:
event the event this behavior is attached to

respond

protected final void respond(AjaxRequestTarget target)
Specified by:
respond in class AbstractDefaultAjaxBehavior
Parameters:
target - The AJAX target
See Also:
AbstractDefaultAjaxBehavior.respond(AjaxRequestTarget)

onEvent

protected abstract void onEvent(AjaxRequestTarget target)
Listener method for the ajax event

Parameters:
target - the current request handler


Copyright © 2006–2020 Apache Software Foundation. All rights reserved.