java.lang.Object
org.apache.wicket.page.PartialPageUpdate
- Direct Known Subclasses:
XmlPartialPageUpdate
A partial update of a page that collects components and header contributions to be written to the
client in a specific String-based format (XML, JSON, * ...).
The elements of such response are:
- component - the markup of the updated component
- header-contribution - all HeaderItems which have been contributed in any
Component.renderHead(IHeaderResponse)
,Behavior.renderHead(Component, IHeaderResponse)
or JavaScript explicitly added viaappendJavaScript(CharSequence)
orprependJavaScript(CharSequence)
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
Wrapper of a response that buffers its contents. -
Field Summary
Modifier and TypeFieldDescriptionprotected final List<CharSequence>
A list of scripts (JavaScript) which should be executed on the client side after the components' replacementprotected final PartialPageUpdate.ResponseBuffer
Buffer of response body.protected boolean
A flag that indicates that components cannot be added anymore.protected final List<CharSequence>
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement.protected HtmlHeaderContainer
protected final PartialPageUpdate.ResponseBuffer
Buffer of response header.protected boolean
A flag that indicates that javascripts cannot be added anymore.The component instances that will be rendered/replaced.protected final List<CharSequence>
A list of scripts (JavaScript) which should be executed on the client side before the components' replacement -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds a component to be updated at the client side with its current markupfinal void
appendJavaScript
(CharSequence javascript) Adds script to the ones which are executed after the component replacement.protected boolean
containsAncestorFor
(Component component) Checks if the target contains an ancestor for the given componentboolean
void
detach
(IRequestCycle requestCycle) Detaches the page if at least one of its components was updated.boolean
final Collection<? extends Component>
Gets or creates an IHeaderResponse instance to use for the header contributions.int
hashCode()
boolean
isEmpty()
protected void
onAfterRespond
(Response response) Hook-method called after components are written.protected void
onBeforeRespond
(Response response) Hook-method called before components are written.protected boolean
prepareComponent
(Component component) Prepare a single componentfinal void
prependJavaScript
(CharSequence javascript) Adds script to the ones which are executed before the component replacement.abstract void
setContentType
(WebResponse response, String encoding) Sets the Content-Type header to indicate the type of the response.protected abstract void
writeComponent
(Response response, String markupId, CharSequence contents) Writes a component to the response.protected void
writeComponent
(Response response, String markupId, Component component, String encoding) Writes a single componentprotected abstract void
writeEvaluation
(Response response, CharSequence contents) Write evaluation.protected void
writeEvaluations
(Response response, Collection<CharSequence> scripts) protected abstract void
writeFooter
(Response response, String encoding) protected abstract void
writeHeader
(Response response, String encoding) Writes the head part of the response.protected abstract void
writeHeaderContribution
(Response response, CharSequence contents) Writes a header contribution to the response.protected void
writeHeaderContribution
(Response response, Component component) protected abstract void
writePriorityEvaluation
(Response response, CharSequence contents) Write priority-evaluation.protected void
writePriorityEvaluations
(Response response, Collection<CharSequence> scripts) void
Serializes this object to the response.
-
Field Details
-
prependJavaScripts
A list of scripts (JavaScript) which should be executed on the client side before the components' replacement -
appendJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement -
domReadyJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement. Executed immediately after the replacement of the components, and before appendJavaScripts -
markupIdToComponent
The component instances that will be rendered/replaced. -
componentsFrozen
A flag that indicates that components cannot be added anymore. See https://issues.apache.org/jira/browse/WICKET-3564- See Also:
-
javascriptsFrozen
A flag that indicates that javascripts cannot be added anymore. See https://issues.apache.org/jira/browse/WICKET-6902 -
bodyBuffer
Buffer of response body. -
headerBuffer
Buffer of response header. -
header
-
-
Constructor Details
-
PartialPageUpdate
Constructor.- Parameters:
page
- the page which components are being updated.
-
-
Method Details
-
isEmpty
- Returns:
- returns true if and only if nothing has being added to partial update.
-
writeTo
Serializes this object to the response.- Parameters:
response
- the response to write toencoding
- the encoding for the response
-
onBeforeRespond
Hook-method called before components are written.- Parameters:
response
-
-
onAfterRespond
Hook-method called after components are written.- Parameters:
response
-
-
writePriorityEvaluations
- Parameters:
response
- the response to write toscripts
- the JavaScripts to evaluate
-
writeEvaluations
- Parameters:
response
- the response to write toscripts
- the JavaScripts to evaluate
-
prepareComponent
Prepare a single component- Parameters:
component
- the component to prepare- Returns:
- whether the component was prepared
-
writeComponent
protected void writeComponent(Response response, String markupId, Component component, String encoding) Writes a single component- Parameters:
response
- the response to write tomarkupId
- the markup id to use for the component replacementcomponent
- the component which markup will be used as replacementencoding
- the encoding for the response
-
writeHeader
Writes the head part of the response. For example XML preamble- Parameters:
response
- the response to write toencoding
- the encoding for the response
-
writeComponent
Writes a component to the response.- Parameters:
response
- the response to write tocontents
- the contents
-
writePriorityEvaluation
Write priority-evaluation. -
writeHeaderContribution
Writes a header contribution to the response.- Parameters:
response
- the response to write tocontents
- the contents
-
writeEvaluation
Write evaluation. -
equals
-
hashCode
-
appendJavaScript
Adds script to the ones which are executed after the component replacement.- Parameters:
javascript
- the javascript to execute
-
prependJavaScript
Adds script to the ones which are executed before the component replacement.- Parameters:
javascript
- the javascript to execute
-
add
Adds a component to be updated at the client side with its current markup- Parameters:
component
- the component to updatemarkupId
- the markup id to use to find the component in the page's markup- Throws:
IllegalArgumentException
- thrown when a Page or an AbstractRepeater is addedIllegalStateException
- thrown when components no more can be added for replacement.
-
getComponents
- Returns:
- a read-only collection of all components which have been added for replacement so far.
-
detach
Detaches the page if at least one of its components was updated.- Parameters:
requestCycle
- the current request cycle
-
containsAncestorFor
Checks if the target contains an ancestor for the given component- Parameters:
component
- the component which ancestors should be checked.- Returns:
true
if target contains an ancestor for the given component
-
containsPage
- Returns:
true
if the page has been added for replacement
-
getHeaderResponse
Gets or creates an IHeaderResponse instance to use for the header contributions.- Returns:
- IHeaderResponse instance to use for the header contributions.
-
writeHeaderContribution
- Parameters:
response
- the response to write tocomponent
- to component which will contribute to the header
-
setContentType
Sets the Content-Type header to indicate the type of the response.- Parameters:
response
- the current we responseencoding
- the encoding to use
-