Package org.apache.wicket.page
Class PartialPageUpdate
- java.lang.Object
-
- org.apache.wicket.page.PartialPageUpdate
-
- Direct Known Subclasses:
XmlPartialPageUpdate
public abstract class PartialPageUpdate extends java.lang.ObjectA 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:
- priority-evaluate - an item of the prepend JavaScripts
- component - the markup of the updated component
- evaluate - an item of the onDomReady and append JavaScripts
- header-contribution - all HeaderItems which have been contributed in components' and their behaviors' #renderHead(Component, IHeaderResponse)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPartialPageUpdate.ResponseBufferWrapper of a response that buffers its contents.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.CharSequence>appendJavaScriptsA list of scripts (JavaScript) which should be executed on the client side after the components' replacementprotected PartialPageUpdate.ResponseBufferbodyBufferBuffer of response body.protected booleancomponentsFrozenA flag that indicates that components cannot be added anymore.protected java.util.List<java.lang.CharSequence>domReadyJavaScriptsA list of scripts (JavaScript) which should be executed on the client side after the components' replacement.protected HtmlHeaderContainerheaderprotected PartialPageUpdate.ResponseBufferheaderBufferBuffer of response header.protected java.util.Map<java.lang.String,Component>markupIdToComponentThe component instances that will be rendered/replaced.protected java.util.List<java.lang.CharSequence>prependJavaScriptsA 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 voidadd(Component component, java.lang.String markupId)Adds a component to be updated at the client side with its current markupvoidappendJavaScript(java.lang.CharSequence javascript)Adds script to the ones which are executed after the component replacement.protected booleancontainsAncestorFor(Component component)Checks if the target contains an ancestor for the given componentbooleancontainsPage()voiddetach(org.apache.wicket.request.IRequestCycle requestCycle)Detaches the page if at least one of its components was updated.booleanequals(java.lang.Object o)java.util.Collection<? extends Component>getComponents()IHeaderResponsegetHeaderResponse()Gets or creates an IHeaderResponse instance to use for the header contributions.inthashCode()protected voidonAfterRespond(org.apache.wicket.request.Response response)Hook-method called after components are written.protected voidonBeforeRespond(org.apache.wicket.request.Response response)Hook-method called before components are written.protected booleanprepareComponent(Component component)Prepare a single componentvoidprependJavaScript(java.lang.CharSequence javascript)Adds script to the ones which are executed before the component replacement.abstract voidsetContentType(org.apache.wicket.request.http.WebResponse response, java.lang.String encoding)Sets the Content-Type header to indicate the type of the response.protected abstract voidwriteComponent(org.apache.wicket.request.Response response, java.lang.String markupId, Component component, java.lang.String encoding)Writes a single componentprotected abstract voidwriteFooter(org.apache.wicket.request.Response response, java.lang.String encoding)protected abstract voidwriteHeader(org.apache.wicket.request.Response response, java.lang.String encoding)Writes the head part of the response.protected abstract voidwriteHeaderContribution(org.apache.wicket.request.Response response)Writes header contribution (<link/> or <script/>) to the response.protected voidwriteHeaderContribution(org.apache.wicket.request.Response response, Component component)protected abstract voidwriteNormalEvaluations(org.apache.wicket.request.Response response, java.util.Collection<java.lang.CharSequence> js)protected abstract voidwritePriorityEvaluations(org.apache.wicket.request.Response response, java.util.Collection<java.lang.CharSequence> js)voidwriteTo(org.apache.wicket.request.Response response, java.lang.String encoding)Serializes this object to the response.
-
-
-
Field Detail
-
prependJavaScripts
protected final java.util.List<java.lang.CharSequence> prependJavaScripts
A list of scripts (JavaScript) which should be executed on the client side before the components' replacement
-
appendJavaScripts
protected final java.util.List<java.lang.CharSequence> appendJavaScripts
A list of scripts (JavaScript) which should be executed on the client side after the components' replacement
-
domReadyJavaScripts
protected final java.util.List<java.lang.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 java.util.Map<java.lang.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)
-
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
-
writeTo
public void writeTo(org.apache.wicket.request.Response response, java.lang.String encoding)Serializes this object to the response.- Parameters:
response- the response to write toencoding- the encoding for the response
-
onBeforeRespond
protected void onBeforeRespond(org.apache.wicket.request.Response response)
Hook-method called before components are written.- Parameters:
response-
-
onAfterRespond
protected void onAfterRespond(org.apache.wicket.request.Response response)
Hook-method called after components are written.- Parameters:
response-
-
writeFooter
protected abstract void writeFooter(org.apache.wicket.request.Response response, java.lang.String encoding)- Parameters:
response- the response to write toencoding- the encoding for the response
-
writePriorityEvaluations
protected abstract void writePriorityEvaluations(org.apache.wicket.request.Response response, java.util.Collection<java.lang.CharSequence> js)- Parameters:
response- the response to write tojs- the JavaScript to evaluate
-
writeNormalEvaluations
protected abstract void writeNormalEvaluations(org.apache.wicket.request.Response response, java.util.Collection<java.lang.CharSequence> js)- Parameters:
response- the response to write tojs- the JavaScript to evaluate
-
prepareComponent
protected boolean prepareComponent(Component component)
Prepare a single component- Parameters:
component- the component to prepare- Returns:
- wether the component was prepared
-
writeComponent
protected abstract void writeComponent(org.apache.wicket.request.Response response, java.lang.String markupId, Component component, java.lang.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(org.apache.wicket.request.Response response, java.lang.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
-
writeHeaderContribution
protected abstract void writeHeaderContribution(org.apache.wicket.request.Response response)
Writes header contribution (<link/> or <script/>) to the response.- Parameters:
response- the response to write to
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
appendJavaScript
public final void appendJavaScript(java.lang.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(java.lang.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, java.lang.String markupId) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
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:
java.lang.IllegalArgumentException- thrown when a Page or an AbstractRepeater is addedjava.lang.IllegalStateException- thrown when components no more can be added for replacement.
-
getComponents
public final java.util.Collection<? extends Component> getComponents()
- Returns:
- a read-only collection of all components which have been added for replacement so far.
-
detach
public void detach(org.apache.wicket.request.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:
trueif target contains an ancestor for the given component
-
containsPage
public boolean containsPage()
- Returns:
trueif 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(org.apache.wicket.request.Response response, Component component)- Parameters:
response- the response to write tocomponent- to component which will contribute to the header
-
setContentType
public abstract void setContentType(org.apache.wicket.request.http.WebResponse response, java.lang.String encoding)Sets the Content-Type header to indicate the type of the response.- Parameters:
response- the current we responseencoding- the encoding to use
-
-