Package org.apache.tapestry.dom

Examples of org.apache.tapestry.dom.Element


    public Document clickSubmit(Element submitButton, Map<String, String> fieldValues)
    {
        final String DEFAULT_SUBMIT_VALUE_ATTRIBUTE = "Submit Query";
        Defense.notNull(submitButton, "submitButton");
        assertIsSubmit(submitButton);
        Element form = getFormAncestor(submitButton);
        String value = submitButton.getAttribute("value");
        if (value == null)
        {
            value = DEFAULT_SUBMIT_VALUE_ATTRIBUTE;
        }
View Full Code Here


    @BeginRender
    void begin(MarkupWriter writer)
    {
        final Field field = _field;

        final Element element = writer.element("label");

        _resources.renderInformalParameters(writer);

        // Uh oh! Referencing a private field (that happens to get instrumented up the wazoo) from
        // a inner class causes a java.lang.Verify error (Unable to pop operand off an empty stack).
        // Perhaps this is a Javassist error? Shouldn't the inner class be going through a synthetic
        // accessor method of some kind? Resolved by assigning to a local variable and referencing
        // that. Layers on layers, oh my!

        final ValidationDecorator decorator = _decorator;

        // Since we don't know if the field has rendered yet, we need to defer writing the for
        // attribute until we know the field has rendered (and set its clientId property). That's
        // exactly what Heartbeat is for.

        Runnable command = new Runnable()
        {
            public void run()
            {
                String fieldId = field.getClientId();

                element.forceAttributes("for", fieldId, "id", fieldId + ":label");

                decorator.insideLabel(field, element);
            }
        };
View Full Code Here

    public void cleanup(Environment environment)
    {
        Document document = environment.peek(Document.class);

        Element head = document.find("html/head");

        if (head == null) return;

        head.elementAt(0, "link", "rel", "stylesheet", "type", "text/css", "href", _stylesheetAsset
                .toClientURL());
    }
View Full Code Here

        component.injectDecorator(new StubValidationDecorator());
        component.injectFormSupport(formSupport);

        component.beginRender(writer);

        Element element = writer.getElement();
        assertNotNull(element);
        assertEquals(element.getName(), "input");
        assertEquals(element.getAttribute("type"), "file");
        // assertEquals(element.getAttribute("name"),null);
        // assertEquals(element.getAttribute("id"),null);

        verify();
View Full Code Here

    public void renderPartial(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");

        // The initialize methods will already have been invoked.

        render(writer);

        writer.end();

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

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

        _scriptBlock.append("\n");
    }

    public void updateDocument(Document document)
    {
        Element root = document.getRootElement();

        // This can happen due to a catastrophic rendering error, such as a missing page template.
        if (root == null) return;

        // This only applies when the document is an HTML document. This may need to change in the
        // future, perhaps configurable, to allow for html and xhtml and perhaps others. Does SVG
        // use stylesheets?

        if (!root.getName().equals("html")) return;

        int stylesheets = _includedStylesheets.size();

        if (stylesheets > 0)
        {
            Element head = root.find("head");

            if (head == null) head = root.elementAt(0, "head");

            for (int i = 0; i < stylesheets; i++)
                _includedStylesheets.get(i).add(head, i);
        }

        Element body = root.find("body");

        if (body == null) return;

        for (int i = 0; i < _scripts.size(); i++)
        {
            String scriptURL = _scripts.get(i);

            body.elementAt(i, "script", "src", scriptURL, "type", "text/javascript");
        }

        if (_scriptBlock.length() > 0)
        {
            Element e = body.element("script", "type", "text/javascript");
            e.raw("\n<!--\n");

            // This assumes that Prototype and tapestry.js is available.

            e.text("Tapestry.onDOMLoaded(function() {\n");

            e.text(_scriptBlock.toString());

            e.text("});\n");

            e.raw("// -->\n");
        }

    }
View Full Code Here

    void beginRender(MarkupWriter writer)
    {
        _clientId = _pageRenderSupport.allocateClientId(_resources.getId());

        Element e = writer.element("div", "id", _clientId);

        _resources.renderInformalParameters(writer);

        e.addClassName("t-zone");

        if (!_visible) e.addClassName("t-invisible");

        // And continue on to render the body

        JSONObject spec = new JSONObject();
        spec.put("div", _clientId);
View Full Code Here

                if (line == current) writer.getElement().addClassName("t-location-current");

                writer.write(Integer.toString(current));
                writer.end();

                Element td = writer.element("td", "class", "t-location-content");

                if (line == current) td.addClassName("t-location-current");

                if (start == current) td.addClassName("t-location-content-first");

                writer.write(input);
                writer.end();

                writer.end(); // tr
View Full Code Here

    {
        notNull(submitButton, "submitButton");

        assertIsSubmit(submitButton);

        Element form = getFormAncestor(submitButton);
        String value = submitButton.getAttribute("value");

        if (value == null) value = DEFAULT_SUBMIT_VALUE_ATTRIBUTE;

        fieldValues.put(submitButton.getAttribute("name"), value);
View Full Code Here

     * @param link           the link that will form the href
     * @param namesAndValues additional attributes to write
     */
    protected final void writeLink(MarkupWriter writer, String clientId, Link link, Object... namesAndValues)
    {
        Element e = writer.element("a", "href", buildHref(link), "id", clientId);

        writer.attributes(namesAndValues);

        _resources.renderInformalParameters(writer);

View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.