Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // Copyright 2009, 2010 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
 // http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry5.services.ajax;
Responsible for capturing the content for a single zone and storing it into the JSON reply object.

    private final String zoneId;
    private final RenderCommand zoneRenderCommand;
    private final PageRenderQueue queue;
    public SingleZonePartialRendererFilter(String zoneIdRenderCommand zoneRenderCommandPageRenderQueue queue,
            AjaxFormUpdateController ajaxFormUpdateController)
    {
        this. = zoneId;
        this. = zoneRenderCommand;
        this. = queue;
        this. = ajaxFormUpdateController;
    }
    public void renderMarkup(MarkupWriter writerfinal JSONObject replyPartialMarkupRenderer renderer)
    {
        RenderCommand forZone = new RenderCommand()
        {
            public void render(MarkupWriter writerRenderQueue 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");
                .setupBeforePartialZoneRender(writer);
                queue.push(new RenderCommand()
                {
                    public void render(MarkupWriter writerRenderQueue queue)
                    {
                        writer.end(); // the zoneContainer element
                        // Need to do this Ajax Form-related cleanup here, before we extract the zone content.
                        .cleanupAfterPartialZoneRender();
                        String zoneUpdateContent = zoneContainer.getChildMarkup();
                        zoneContainer.remove();
                        reply.getJSONObject("zones").put(zoneUpdateContent);
                    }
                });
                // Make sure the zone's actual rendering command is processed first, then the inline
                // RenderCommand just above.
                queue.push();
            }
        };
        RenderCommand existing = .getRootRenderCommand();
        .initializeForPartialPageRender(new CombinedRenderCommand(existingforZone));
        renderer.renderMarkup(writerreply);
    }
New to GrepCode? Check out our FAQ X