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
INTERFACE
Constructor and Description |
---|
AjaxEventBehavior(String event)
Construct.
|
Modifier and Type | Method and Description |
---|---|
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.
|
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
beforeRender, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onConfigure, onEvent, onException, onRemove
public AjaxEventBehavior(String event)
event
- the event this behavior will be attached topublic void renderHead(Component component, IHeaderResponse response)
Behavior
renderHead
in interface IComponentAwareHeaderContributor
renderHead
in class AbstractDefaultAjaxBehavior
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 objectBehavior.renderHead(Component,
org.apache.wicket.markup.head.IHeaderResponse)
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
AbstractDefaultAjaxBehavior
updateAjaxAttributes
in class AbstractDefaultAjaxBehavior
protected void onCheckEvent(String event)
event
- the event this behavior will be attached topublic String getEvent()
protected final void respond(AjaxRequestTarget target)
respond
in class AbstractDefaultAjaxBehavior
target
- The AJAX targetAbstractDefaultAjaxBehavior.respond(AjaxRequestTarget)
protected abstract void onEvent(AjaxRequestTarget target)
target
- the current request handlerCopyright © 2006–2018 Apache Software Foundation. All rights reserved.