Example usage for org.apache.wicket Component getAjaxRegionMarkupId

List of usage examples for org.apache.wicket Component getAjaxRegionMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket Component getAjaxRegionMarkupId.

Prototype

public final String getAjaxRegionMarkupId() 

Source Link

Document

Returns the id of the markup region that will be updated via ajax.

Usage

From source file:sf.wicklet.gwt.server.ajax.impl.AbstractGwtAjaxResponse.java

License:Apache License

/**
 * Processes components added to the target. This involves attaching components, rendering
 * markup into a client side xml envelope, and detaching them
 *
 * @param response/*from w  w w .j  a  va 2  s . c  om*/
 *      the response to write to
 * @param encoding
 *      the encoding for the response
 */
private void writeComponents(final Response response, final String encoding) {
    componentsFrozen = true;
    // process component markup
    for (final Map.Entry<String, Component> stringComponentEntry : markupIdToComponent.entrySet()) {
        final Component component = stringComponentEntry.getValue();
        // final String markupId = stringComponentEntry.getKey();
        if (!containsAncestorFor(component)) {
            writeComponent(response, component.getAjaxRegionMarkupId(), component, encoding);
        }
    }
    for (final Map.Entry<String, String> e : markupIdToXml.entrySet()) {
        final String xml = e.getValue();
        writeComponentXml(response, e.getKey(), XmlUtil.escXml(xml).toString(), encoding);
    }
    for (final Map.Entry<String, String> e : markupIdToHeaderXml.entrySet()) {
        final String xml = e.getValue();
        writeHeaderXml(response, e.getKey(), XmlUtil.escXml(xml).toString(), encoding);
    }
    if (header != null) {
        // some header responses buffer all calls to render*** until close is called.
        // when they are closed, they do something (i.e. aggregate all JS resource urls to a
        // single url), and then "flush" (by writing to the real response) before closing.
        // to support this, we need to allow header contributions to be written in the close
        // tag, which we do here:
        headerRendering = true;
        // save old response, set new
        final Response oldResponse = RequestCycle.get().setResponse(encodingHeaderResponse);
        encodingHeaderResponse.reset();
        // now, close the response (which may render things)
        header.getHeaderResponse().close();
        // revert to old response
        RequestCycle.get().setResponse(oldResponse);
        // write the XML tags and we're done
        writeHeaderContribution(response);
        headerRendering = false;
    }
}