Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Element$Attribute


    {
        assert submitButton != null;

        assertIsSubmit(submitButton);

        Element form = getFormAncestor(submitButton);

        request.clear().setPath(stripContextFromPath(extractNonBlank(form, "action")));

        pushFieldValuesIntoRequest(form);
View Full Code Here


        return findAncestor(element, "form");
    }

    private Element findAncestor(Element element, String ancestorName)
    {
        Element e = element;

        while (e != null)
        {
            if (e.getName().equalsIgnoreCase(ancestorName))
                return e;

            e = e.getContainer();
        }

        throw new RuntimeException(String.format("Could not locate an ancestor element of type '%s'.", ancestorName));

    }
View Full Code Here

            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)
                    {
                        writer.end(); // the zoneContainer element

                        // Need to do this Ajax Form-related cleanup here, before we extract the zone content.

                        ajaxFormUpdateController.cleanupAfterPartialZoneRender();

                        String zoneUpdateContent = zoneContainer.getChildMarkup();

                        zoneContainer.remove();

                        reply.getJSONObject("zones").put(zoneId, zoneUpdateContent);
                    }
                });
View Full Code Here

    Block beginRender(MarkupWriter writer)
    {
        String clientId = renderSupport.allocateClientId(resources);
        String elementName = resources.getElementName("div");

        Element e = writer.element(elementName, "id", clientId);

        resources.renderInformalParameters(writer);

        e.addClassName("t-zone");

        Link link = resources.createEventLink(EventConstants.ACTION, context);

        JSONObject spec = new JSONObject();
View Full Code Here

    public void renderMarkup(MarkupWriter writer, JSONObject reply)
    {
        // The partial will quite often contain multiple elements (or just a block of plain text),
        // so those must be enclosed in a root element.

        Element root = writer.element("ajax-partial");

        renderQueue.renderPartial(writer, reply);

        writer.end();

        String content = root.getChildMarkup().trim();

        reply.put("content", content);
    }
View Full Code Here

     * @param document
     *            to be updated
     */
    public void updateDocument(Document document)
    {
        Element root = document.getRootElement();

        // If the document failed to render at all, that's a different problem and is reported elsewhere.

        if (root == null)
            return;

        addStylesheetsToHead(root, includedStylesheets);

        // only add the generator meta only to html documents

        boolean isHtmlRoot = root.getName().equals("html");

        if (!omitGeneratorMetaTag && isHtmlRoot)
        {
            Element head = findOrCreateElement(root, "head", true);
            head.element("meta", "name", "generator", "content", tapestryBanner);
        }

        addScriptElements(root);
    }
View Full Code Here

        String rootElementName = root.getName();

        if (!rootElementName.equals("html"))
            throw new RuntimeException(ServicesMessages.documentMissingHTMLRoot(rootElementName));

        Element container = findOrCreateElement(root, "head", true);

        // TAPESTRY-2364

        addScriptLinksForIncludedScripts(container, scripts);
View Full Code Here

            addDynamicScriptBlock(findOrCreateElement(root, "body", false));
    }

    private Element findOrCreateElement(Element root, String childElement, boolean atTop)
    {
        Element container = root.find(childElement);

        // Create the element is it is missing.

        if (container == null)
            container = atTop ? root.elementAt(0, childElement) : root.element(childElement);
View Full Code Here

        }

        if (wrapped)
            block.append("});\n");

        Element e = body.element("script", "type", "text/javascript");

        e.raw(block.toString());

    }
View Full Code Here

     * @param scripts
     *            scripts to add
     */
    protected void addScriptLinksForIncludedScripts(Element container, List<String> scripts)
    {
        Element existing = findExistingElement(container, "script");

        final Element scriptContainer = container.element("script-container");

        Worker<String> addScript = new Worker<String>()
        {
            public void work(String scriptURL)
            {
                scriptContainer.element("script", "type", "text/javascript", "src", scriptURL);
            }
        };

        F.flow(scripts).each(addScript);

        if (existing != null)
            scriptContainer.moveBefore(existing);

        scriptContainer.pop();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.dom.Element$Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.