Package org.apache.wicket.page
Class PartialPageUpdate
- java.lang.Object
-
- org.apache.wicket.page.PartialPageUpdate
-
- Direct Known Subclasses:
XmlPartialPageUpdate
public abstract class PartialPageUpdate extends Object
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
Nested Classes Modifier and Type Class Description protected static class
PartialPageUpdate.ResponseBuffer
Wrapper of a response that buffers its contents.
-
Field Summary
Fields Modifier and Type Field Description protected List<CharSequence>
appendJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacementprotected PartialPageUpdate.ResponseBuffer
bodyBuffer
Buffer of response body.protected boolean
componentsFrozen
A flag that indicates that components cannot be added anymore.protected List<CharSequence>
domReadyJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement.protected HtmlHeaderContainer
header
protected PartialPageUpdate.ResponseBuffer
headerBuffer
Buffer of response header.protected boolean
javascriptsFrozen
A flag that indicates that javascripts cannot be added anymore.protected Map<String,Component>
markupIdToComponent
The component instances that will be rendered/replaced.protected List<CharSequence>
prependJavaScripts
A list of scripts (JavaScript) which should be executed on the client side before the components' replacement
-
Constructor Summary
Constructors Constructor Description PartialPageUpdate(Page page)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(Component component, String markupId)
Adds a component to be updated at the client side with its current markupvoid
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
containsPage()
void
detach(IRequestCycle requestCycle)
Detaches the page if at least one of its components was updated.boolean
equals(Object o)
Collection<? extends Component>
getComponents()
IHeaderResponse
getHeaderResponse()
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 componentvoid
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 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 void
writeEvaluation(Response response, CharSequence contents)
TODO make abstract in Wicket 10protected 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 void
writePriorityEvaluation(Response response, CharSequence contents)
TODO make abstract in Wicket 10protected void
writePriorityEvaluations(Response response, Collection<CharSequence> scripts)
void
writeTo(Response response, String encoding)
Serializes this object to the response.
-
-
-
Field Detail
-
prependJavaScripts
protected final List<CharSequence> prependJavaScripts
A list of scripts (JavaScript) which should be executed on the client side before the components' replacement
-
appendJavaScripts
protected final List<CharSequence> appendJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement
-
domReadyJavaScripts
protected final List<CharSequence> 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
protected final Map<String,Component> markupIdToComponent
The component instances that will be rendered/replaced.
-
componentsFrozen
protected transient boolean componentsFrozen
A flag that indicates that components cannot be added anymore. See https://issues.apache.org/jira/browse/WICKET-3564- See Also:
add(Component, String)
-
javascriptsFrozen
protected transient boolean javascriptsFrozen
A flag that indicates that javascripts cannot be added anymore. See https://issues.apache.org/jira/browse/WICKET-6902
-
bodyBuffer
protected final PartialPageUpdate.ResponseBuffer bodyBuffer
Buffer of response body.
-
headerBuffer
protected final PartialPageUpdate.ResponseBuffer headerBuffer
Buffer of response header.
-
header
protected HtmlHeaderContainer header
-
-
Constructor Detail
-
PartialPageUpdate
public PartialPageUpdate(Page page)
Constructor.- Parameters:
page
- the page which components are being updated.
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
- Returns:
- returns true if and only if nothing has being added to partial update.
-
writeTo
public void writeTo(Response response, String encoding)
Serializes this object to the response.- Parameters:
response
- the response to write toencoding
- the encoding for the response
-
onBeforeRespond
protected void onBeforeRespond(Response response)
Hook-method called before components are written.- Parameters:
response
-
-
onAfterRespond
protected void onAfterRespond(Response response)
Hook-method called after components are written.- Parameters:
response
-
-
writeFooter
protected abstract void writeFooter(Response response, String encoding)
- Parameters:
response
- the response to write toencoding
- the encoding for the response
-
writePriorityEvaluations
protected void writePriorityEvaluations(Response response, Collection<CharSequence> scripts)
- Parameters:
response
- the response to write toscripts
- the JavaScripts to evaluate
-
writeEvaluations
protected void writeEvaluations(Response response, Collection<CharSequence> scripts)
- Parameters:
response
- the response to write toscripts
- the JavaScripts to evaluate
-
prepareComponent
protected boolean prepareComponent(Component component)
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
protected abstract void writeHeader(Response response, String encoding)
Writes the head part of the response. For example XML preamble- Parameters:
response
- the response to write toencoding
- the encoding for the response
-
writeComponent
protected void writeComponent(Response response, String markupId, CharSequence contents)
Writes a component to the response.TODO make abstract in Wicket 10
- Parameters:
response
- the response to write tocontents
- the contents
-
writePriorityEvaluation
protected void writePriorityEvaluation(Response response, CharSequence contents)
TODO make abstract in Wicket 10
-
writeHeaderContribution
protected abstract void writeHeaderContribution(Response response, CharSequence contents)
Writes a header contribution to the response.- Parameters:
response
- the response to write tocontents
- the contents
-
writeEvaluation
protected void writeEvaluation(Response response, CharSequence contents)
TODO make abstract in Wicket 10
-
appendJavaScript
public final void appendJavaScript(CharSequence javascript)
Adds script to the ones which are executed after the component replacement.- Parameters:
javascript
- the javascript to execute
-
prependJavaScript
public final void prependJavaScript(CharSequence javascript)
Adds script to the ones which are executed before the component replacement.- Parameters:
javascript
- the javascript to execute
-
add
public final void add(Component component, String markupId)
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
public final Collection<? extends Component> getComponents()
- Returns:
- a read-only collection of all components which have been added for replacement so far.
-
detach
public void detach(IRequestCycle requestCycle)
Detaches the page if at least one of its components was updated.- Parameters:
requestCycle
- the current request cycle
-
containsAncestorFor
protected boolean containsAncestorFor(Component component)
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
public boolean containsPage()
- Returns:
true
if the page has been added for replacement
-
getHeaderResponse
public IHeaderResponse getHeaderResponse()
Gets or creates an IHeaderResponse instance to use for the header contributions.- Returns:
- IHeaderResponse instance to use for the header contributions.
-
writeHeaderContribution
protected void writeHeaderContribution(Response response, Component component)
- Parameters:
response
- the response to write tocomponent
- to component which will contribute to the header
-
setContentType
public abstract void setContentType(WebResponse response, String encoding)
Sets the Content-Type header to indicate the type of the response.- Parameters:
response
- the current we responseencoding
- the encoding to use
-
-