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:

  • Field Details

  • Constructor Details

    • PartialPageUpdate

      public PartialPageUpdate(Page page)
      Constructor.
      Parameters:
      page - the page which components are being updated.
  • Method Details

    • 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 to
      encoding - 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 to
      encoding - the encoding for the response
    • writePriorityEvaluations

      protected void writePriorityEvaluations(Response response, Collection<CharSequence> scripts)
      Parameters:
      response - the response to write to
      scripts - the JavaScripts to evaluate
    • writeEvaluations

      protected void writeEvaluations(Response response, Collection<CharSequence> scripts)
      Parameters:
      response - the response to write to
      scripts - 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 to
      markupId - the markup id to use for the component replacement
      component - the component which markup will be used as replacement
      encoding - 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 to
      encoding - the encoding for the response
    • writeComponent

      protected abstract void writeComponent(Response response, String markupId, CharSequence contents)
      Writes a component to the response.
      Parameters:
      response - the response to write to
      contents - the contents
    • writePriorityEvaluation

      protected abstract void writePriorityEvaluation(Response response, CharSequence contents)
      Write priority-evaluation.
    • writeHeaderContribution

      protected abstract void writeHeaderContribution(Response response, CharSequence contents)
      Writes a header contribution to the response.
      Parameters:
      response - the response to write to
      contents - the contents
    • writeEvaluation

      protected abstract void writeEvaluation(Response response, CharSequence contents)
      Write evaluation.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 update
      markupId - the markup id to use to find the component in the page's markup
      Throws:
      IllegalArgumentException - thrown when a Page or an AbstractRepeater is added
      IllegalStateException - 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

      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 to
      component - 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 response
      encoding - the encoding to use