- All Implemented Interfaces:
AjaxRequestTarget
,IPageClassRequestHandler
,IPageRequestHandler
,IPartialPageRequestHandler
,ILoggableRequestHandler
,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
(IRequestCycle requestCycle) This method is called at the end of a request cycle to indicate that processing is done and that cleaning up of the subject(s) of this target may be done.boolean
final Collection<? extends Component>
Returns an unmodifiable collection of all components added to this targetReturns the HTML id of the last focused element.Returns the collected log data for this request handler and should never throw an exception.int
hashCode()
void
Register the given respond listener.final void
respond
(IRequestCycle requestCycle) Generates a response.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
Description copied from interface:IRequestHandler
This method is called at the end of a request cycle to indicate that processing is done and that cleaning up of the subject(s) of this target may be done.- Specified by:
detach
in interfaceIRequestHandler
- Parameters:
requestCycle
- the current request cycle- See Also:
-
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
Description copied from interface:IRequestHandler
Generates a response.- Specified by:
respond
in interfaceIRequestHandler
- Parameters:
requestCycle
- the current request cycle- See Also:
-
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
Description copied from interface:ILoggableRequestHandler
Returns the collected log data for this request handler and should never throw an exception. This method is never called before the request handler is detached.- Specified by:
getLogData
in interfaceILoggableRequestHandler
- Returns:
- The collected log data.
-