Package org.apache.wicket.ajax
Class AjaxEventBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.behavior.AbstractAjaxBehavior
-
- org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
- org.apache.wicket.ajax.AjaxEventBehavior
-
- All Implemented Interfaces:
java.io.Serializable,IComponentAwareEventSink,IRequestListener,IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
AjaxFormComponentUpdatingBehavior,AjaxFormSubmitBehavior,AjaxPagingNavigationBehavior,AjaxPreventSubmitBehavior
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 theonEvent(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 thengetEvent()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
-
-
Constructor Summary
Constructors Constructor Description AjaxEventBehavior(java.lang.String event)Construct.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetEvent()static AjaxEventBehavioronEvent(java.lang.String eventName, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onEvent)Creates anAjaxEventBehaviorbased on lambda expressionsprotected abstract voidonEvent(AjaxRequestTarget target)Listener method for the ajax eventvoidrenderHead(Component component, IHeaderResponse response)Render to the web response whatever the component wants to contribute to the head section.protected voidrespond(AjaxRequestTarget target)protected voidupdateAjaxAttributes(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, 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, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag
-
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
-
renderHead
public void renderHead(Component component, IHeaderResponse response)
Description copied from class:BehaviorRender to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHeadin interfaceIComponentAwareHeaderContributor- Overrides:
renderHeadin classAbstractDefaultAjaxBehavior- 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 interfaceresponse- Response object- See Also:
Behavior.renderHead(Component, org.apache.wicket.markup.head.IHeaderResponse)
-
updateAjaxAttributes
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
Description copied from class:AbstractDefaultAjaxBehaviorGives a chance to the specializations to modify the attributes.- Overrides:
updateAjaxAttributesin classAbstractDefaultAjaxBehavior
-
getEvent
public java.lang.String getEvent()
- Returns:
- event the event this behavior is attached to
-
respond
protected final void respond(AjaxRequestTarget target)
- Specified by:
respondin classAbstractDefaultAjaxBehavior- Parameters:
target- The AJAX target
-
onEvent
protected abstract void onEvent(AjaxRequestTarget target)
Listener method for the ajax event- Parameters:
target- the current request handler
-
onEvent
public static AjaxEventBehavior onEvent(java.lang.String eventName, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onEvent)
Creates anAjaxEventBehaviorbased on lambda expressions- Parameters:
eventName- the event nameonEvent- theSerializableConsumerwhich accepts theAjaxRequestTarget- Returns:
- the
AjaxEventBehavior
-
-