Search in sources :

Example 6 with Zone

use of org.apache.tapestry5.corelib.components.Zone in project tapestry-5 by apache.

the class SingleZonePartialRendererFilter method renderMarkup.

public void renderMarkup(MarkupWriter writer, final JSONObject reply, PartialMarkupRenderer renderer) {
    RenderCommand forZone = new RenderCommand() {

        public void render(MarkupWriter writer, RenderQueue queue) {
            // Create an element to contain the content for the zone. We give it a mnemonic
            // element name and attribute just to help with debugging (the element itself is discarded).
            final Element zoneContainer = writer.element("zone-update", "zoneId", zoneId);
            ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
            queue.push(new RenderCommand() {

                public void render(MarkupWriter writer, RenderQueue queue) {
                    // the zoneContainer element
                    writer.end();
                    // Need to do this Ajax Form-related cleanup here, before we extract the zone content.
                    ajaxFormUpdateController.cleanupAfterPartialZoneRender();
                    String zoneUpdateContent = zoneContainer.getChildMarkup();
                    zoneContainer.remove();
                    // This has changed a bit in 5.4;
                    // In 5.3, it was just "zones", and was key/value pairs for id and content.
                    // In 5.4, it is "content", and is an array of id/content arrays
                    reply.in(InternalConstants.PARTIAL_KEY).append("content", new JSONArray(zoneId, zoneUpdateContent));
                }
            });
            // Make sure the zone's actual rendering command is processed first, then the inline
            // RenderCommand just above.
            queue.push(zoneRenderCommand);
        }
    };
    queue.addPartialRenderer(forZone);
    renderer.renderMarkup(writer, reply);
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) Element(org.apache.tapestry5.dom.Element) JSONArray(org.apache.tapestry5.json.JSONArray) PageRenderQueue(org.apache.tapestry5.internal.services.PageRenderQueue) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter)

Example 7 with Zone

use of org.apache.tapestry5.corelib.components.Zone in project tapestry-5 by apache.

the class ProgressiveDisplay method beginRender.

Block beginRender(MarkupWriter writer) {
    String clientId = jsSupport.allocateClientId(resources);
    String elementName = resources.getElementName("div");
    writer.element(elementName, "id", clientId, "data-container-type", "zone");
    resources.renderInformalParameters(writer);
    Link link = resources.createEventLink(EventConstants.ACTION, context);
    jsSupport.require("t5/core/zone").invoke("deferredZoneUpdate").with(clientId, link.toURI());
    // of the component.
    return initial;
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 8 with Zone

use of org.apache.tapestry5.corelib.components.Zone in project tapestry-5 by apache.

the class Zone method beginRender.

void beginRender(MarkupWriter writer) {
    clientId = resources.isBound("id") ? idParameter : javascriptSupport.allocateClientId(resources);
    Element e = writer.element(elementName, "id", clientId, "data-container-type", "zone");
    if (simpleIds) {
        e.attribute("data-simple-ids", "true");
    }
    resources.renderInformalParameters(writer);
    insideForm = formSupport != null;
    if (insideForm) {
        JSONObject parameters = new JSONObject(RequestConstants.FORM_CLIENTID_PARAMETER, formSupport.getClientId(), RequestConstants.FORM_COMPONENTID_PARAMETER, formSupport.getFormComponentId());
        e.attribute("data-zone-parameters", parameters.toString(compactJSON));
        hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules);
        actionSink = new ComponentActionSink(logger, clientDataEncoder);
        environment.push(FormSupport.class, new FormSupportAdapter(formSupport) {

            @Override
            public <T> void store(T component, ComponentAction<T> action) {
                actionSink.store(component, action);
            }

            @Override
            public <T> void storeCancel(T component, ComponentAction<T> action) {
                actionSink.storeCancel(component, action);
            }

            @Override
            public <T> void storeAndExecute(T component, ComponentAction<T> action) {
                store(component, action);
                action.execute(component);
            }
        });
    }
    heartbeat.begin();
}
Also used : ComponentActionSink(org.apache.tapestry5.corelib.internal.ComponentActionSink) HiddenFieldPositioner(org.apache.tapestry5.corelib.internal.HiddenFieldPositioner) JSONObject(org.apache.tapestry5.json.JSONObject) Element(org.apache.tapestry5.dom.Element) FormSupportAdapter(org.apache.tapestry5.corelib.internal.FormSupportAdapter)

Example 9 with Zone

use of org.apache.tapestry5.corelib.components.Zone in project tapestry-5 by apache.

the class AbstractComponentEventLink method beginRender.

void beginRender(MarkupWriter writer) {
    if (isDisabled())
        return;
    Link link = createLink(context);
    writeLink(writer, link);
    writer.attributes("data-update-zone", zone);
    if (async) {
        javaScriptSupport.require("t5/core/zone");
        writer.attributes("data-async-trigger", true);
    }
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 10 with Zone

use of org.apache.tapestry5.corelib.components.Zone in project tapestry-5 by apache.

the class Select method beginRender.

void beginRender(MarkupWriter writer) {
    writer.element("select", "name", getControlName(), "id", getClientId(), "class", cssClass);
    putPropertyNameIntoBeanValidationContext("value");
    validate.render(writer);
    removePropertyNameFromBeanValidationContext();
    resources.renderInformalParameters(writer);
    decorateInsideField();
    if (this.zone != null) {
        javaScriptSupport.require("t5/core/select");
        Link link = resources.createEventLink(CHANGE_EVENT, context);
        writer.attributes("data-update-zone", zone, "data-update-url", link);
    }
}
Also used : Link(org.apache.tapestry5.http.Link)

Aggregations

Link (org.apache.tapestry5.http.Link)6 ComponentActionSink (org.apache.tapestry5.corelib.internal.ComponentActionSink)2 Element (org.apache.tapestry5.dom.Element)2 JSONObject (org.apache.tapestry5.json.JSONObject)2 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MarkupWriter (org.apache.tapestry5.MarkupWriter)1 MultiZoneUpdate (org.apache.tapestry5.ajax.MultiZoneUpdate)1 AfterRender (org.apache.tapestry5.annotations.AfterRender)1 BeginRender (org.apache.tapestry5.annotations.BeginRender)1 FormSupportAdapter (org.apache.tapestry5.corelib.internal.FormSupportAdapter)1 HiddenFieldPositioner (org.apache.tapestry5.corelib.internal.HiddenFieldPositioner)1 BeanValidationContextImpl (org.apache.tapestry5.internal.BeanValidationContextImpl)1 PageRenderQueue (org.apache.tapestry5.internal.services.PageRenderQueue)1 AutofocusValidationDecorator (org.apache.tapestry5.internal.util.AutofocusValidationDecorator)1 IdAllocator (org.apache.tapestry5.ioc.util.IdAllocator)1 JSONArray (org.apache.tapestry5.json.JSONArray)1 RenderQueue (org.apache.tapestry5.runtime.RenderQueue)1 Heartbeat (org.apache.tapestry5.services.Heartbeat)1 JavaScriptCallback (org.apache.tapestry5.services.ajax.JavaScriptCallback)1