public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
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.
onEvent(AjaxRequestTarget),
Serialized FormINDICATOR| Constructor and Description |
|---|
AjaxEventBehavior(String event)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getEvent() |
protected abstract void |
onEvent(AjaxRequestTarget target)
Listener method for the ajax event
|
static AjaxEventBehavior |
onEvent(String eventName,
org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onEvent)
Creates an
AjaxEventBehavior based on lambda expressions |
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.
|
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributesafterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbindbeforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTagclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrendersPagepublic AjaxEventBehavior(String event)
event - the event this behavior will be attached topublic void renderHead(Component component, IHeaderResponse response)
BehaviorrenderHead in interface IComponentAwareHeaderContributorrenderHead in class AbstractDefaultAjaxBehaviorcomponent - 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 objectBehavior.renderHead(Component,
org.apache.wicket.markup.head.IHeaderResponse)protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
AbstractDefaultAjaxBehaviorupdateAjaxAttributes in class AbstractDefaultAjaxBehaviorpublic String getEvent()
protected final void respond(AjaxRequestTarget target)
respond in class AbstractDefaultAjaxBehaviortarget - The AJAX targetprotected abstract void onEvent(AjaxRequestTarget target)
target - the current request handlerpublic static AjaxEventBehavior onEvent(String eventName, org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onEvent)
AjaxEventBehavior based on lambda expressionseventName - the event nameonEvent - the SerializableConsumer which accepts the AjaxRequestTargetAjaxEventBehaviorCopyright © 2006–2018 Apache Software Foundation. All rights reserved.