Class AjaxRequestHandler
- All Implemented Interfaces:
AjaxRequestTarget
,IPageClassRequestHandler
,IPageRequestHandler
,IPartialPageRequestHandler
,org.apache.wicket.request.ILoggableRequestHandler
,org.apache.wicket.request.IRequestHandler
A component whose markup needs to be updated should be added to this target via AjaxRequestTarget#add(Component) method. Its body will be rendered and added to the envelope when the target is processed, and refreshed on the client side when the ajax response is received.
It is important that the component whose markup needs to be updated contains an id attribute in the generated markup that is equal to the value retrieved from Component#getMarkupId(). This can be accomplished by either setting the id attribute in the html template, or using an attribute modifier that will add the attribute with value Component#getMarkupId() to the tag ( such as MarkupIdSetter )
Any javascript that needs to be evaluated on the client side can be added using AjaxRequestTarget#append/prependJavaScript(String). For example, this feature can be useful when it is desirable to link component update with some javascript effects.
The target provides a listener interface AjaxRequestTarget.IListener
that can be used to
add code that responds to various target events by adding listeners via
addListener(AjaxRequestTarget.IListener)
- Since:
- 1.2
- Author:
- Igor Vaynberg (ivaynberg), Eelco Hillenius
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.wicket.ajax.AjaxRequestTarget
AjaxRequestTarget.IListener, AjaxRequestTarget.ITargetRespondListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
see https://issues.apache.org/jira/browse/WICKET-3564 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(AjaxRequestTarget.IListener listener) Adds a listener to this targetvoid
detach
(org.apache.wicket.request.IRequestCycle requestCycle) boolean
final Collection<? extends Component>
Returns an unmodifiable collection of all components added to this targetReturns the HTML id of the last focused element.int
hashCode()
void
Register the given respond listener.final void
respond
(org.apache.wicket.request.IRequestCycle requestCycle) toString()
Methods inherited from class org.apache.wicket.core.request.handler.AbstractPartialPageRequestHandler
add, add, addChildren, appendJavaScript, focusComponent, getHeaderResponse, getPage, getPageClass, getPageId, getPageParameters, getRenderCount, isPageInstanceCreated, prependJavaScript
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.ajax.AjaxRequestTarget
getPage
Methods inherited from interface org.apache.wicket.core.request.handler.IPageClassRequestHandler
getPageClass, getPageParameters
Methods inherited from interface org.apache.wicket.core.request.handler.IPageRequestHandler
getPageId, getRenderCount, isPageInstanceCreated
Methods inherited from interface org.apache.wicket.core.request.handler.IPartialPageRequestHandler
add, add, addChildren, appendJavaScript, focusComponent, getHeaderResponse, prependJavaScript
-
Field Details
-
respondersFrozen
see https://issues.apache.org/jira/browse/WICKET-3564 -
listenersFrozen
-
-
Constructor Details
-
AjaxRequestHandler
Constructor- Parameters:
page
- the currently active page
-
-
Method Details
-
addListener
Description copied from interface:AjaxRequestTarget
Adds a listener to this target- Specified by:
addListener
in interfaceAjaxRequestTarget
- Throws:
IllegalStateException
- ifAjaxRequestTarget.IListener
's events are currently being fired or have both been fired already
-
getUpdate
- Specified by:
getUpdate
in classAbstractPartialPageRequestHandler
-
getComponents
Description copied from interface:IPartialPageRequestHandler
Returns an unmodifiable collection of all components added to this target- Specified by:
getComponents
in interfaceIPartialPageRequestHandler
- Returns:
- unmodifiable collection of all components added to this target
-
detach
- Specified by:
detach
in interfaceorg.apache.wicket.request.IRequestHandler
- See Also:
-
IRequestHandler.detach(org.apache.wicket.request.IRequestCycle)
-
equals
-
hashCode
-
registerRespondListener
Description copied from interface:AjaxRequestTarget
Register the given respond listener. The listener'sAjaxRequestTarget.ITargetRespondListener.onTargetRespond(org.apache.wicket.ajax.AjaxRequestTarget)
method will be invoked when theAjaxRequestTarget
starts to respond.- Specified by:
registerRespondListener
in interfaceAjaxRequestTarget
-
respond
- Specified by:
respond
in interfaceorg.apache.wicket.request.IRequestHandler
- See Also:
-
IRequestHandler.respond(org.apache.wicket.request.IRequestCycle)
-
toString
-
getLastFocusedElementId
Description copied from interface:AjaxRequestTarget
Returns the HTML id of the last focused element.- Specified by:
getLastFocusedElementId
in interfaceAjaxRequestTarget
- Returns:
- the markup id of the focused element in the browser
-
getLogData
- Specified by:
getLogData
in interfaceorg.apache.wicket.request.ILoggableRequestHandler
-