Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Element


    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);
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;
        }

        // TAP5-2200: Generating XML from pages and templates is not possible anymore
        // only add JavaScript and CSS if we're actually generating
        final String mimeType = document.getMimeType();
        if (mimeType != null && !HTML_MIME_TYPES.contains(mimeType))
        {
            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);

            Element existingMeta = head.find("meta");

            addElementBefore(head, existingMeta, "meta", "name", "generator", "content", tapestryBanner);
        }

        addScriptElements(root);
View Full Code Here

    private void addScriptElements(Element root)
    {
        String rootElementName = root.getName();

        Element body = rootElementName.equals("html") ? findOrCreateElement(root, "body", false) : null;

        // Write the data-page-initialized attribute in for all pages; it will be "true" when the page has no
        // initializations (which is somewhat rare in Tapestry). When the page has initializations, it will be set to
        // "true" once those initializations all run.
        if (body != null)
        {
            body.attribute("data-page-initialized", Boolean.toString(!hasScriptsOrInitializations));
        }

        if (!hasScriptsOrInitializations)
        {
            return;
View Full Code Here

     *         if not found, create new element at top of root, or at bottom
     * @return the located element, or null
     */
    private Element findOrCreateElement(Element root, String childElement, boolean atTop)
    {
        Element container = root.find(childElement);

        // Create the element is it is missing.

        if (container == null)
        {
View Full Code Here

        {
            // This adds a mask element to the page, based on the Bootstrap modal dialog backdrop. The mark
            // is present immediately, but fades in visually after a short delay, and is removed
            // after page initialization is complete. For a client that doesn't have JavaScript enabled,
            // this will do nothing (though I suspect the page will not behave to expectations!).
            Element script = body.element("script", "type", "text/javascript");
            script.raw("document.write(\"<div class=\\\"pageloading-mask\\\"><div></div></div>\");");

            script.moveToTop(body);
        }

        moduleManager.writeConfiguration(body, moduleConfigurationCallbacks);

        // Write the core libraries, which includes RequireJS:
View Full Code Here

        moduleManager.writeInitialization(body, libraryURLs, initsManager.getSortedInits());
    }

    private static Element createTemporaryContainer(Element headElement, String existingElementName, String newElementName)
    {
        Element existingScript = headElement.find(existingElementName);

        // Create temporary container for the new <script> elements

        return addElementBefore(headElement, existingScript, newElementName);
    }
View Full Code Here

        if (!rootElementName.equals("html"))
        {
            return;
        }

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

        // Create a temporary container element.
        Element container = createTemporaryContainer(head, "style", "stylesheet-container");

        for (int i = 0; i < count; i++)
        {
            stylesheets.get(i).add(container);
        }

        container.pop();
    }
View Full Code Here

    }

    public void writeConfiguration(Element body,
                                   List<ModuleConfigurationCallback> callbacks)
    {
        Element element = body.element("script", "type", "text/javascript");

        // Build it each time because we don't know if the client supports GZip or not, and
        // (in development mode) URLs for some referenced assets could change (due to URLs
        // containing a checksum on the resource content).
        element.raw(buildRequireJSConfig(callbacks));
    }
View Full Code Here

    }

    public void writeInitialization(Element body, List<String> libraryURLs, List<?> inits)
    {

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

        element.raw(globalMessages.format("private-core-page-initialization-template",
                convert(libraryURLs),
                convert(inits)));
    }
View Full Code Here

    public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer)
    {
        renderer.renderMarkup(writer);

        Element head = writer.getDocument().find("html/head");

        // Only add the respective style documents if we've rendered an HTML document
        if (head != null)
        {
            head.raw(ie9);
            head.raw(ie8);
        }
    }
View Full Code Here

TOP

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

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.