Package org.apache.tapestry.dom

Examples of org.apache.tapestry.dom.Element


    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void not_in_form()
    {
        Element submitButton = _doc.getElementById("orphanedSubmit");
        _tester.clickSubmit(submitButton, _fieldValues);
    }
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

    {
        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

        _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 is available.

            e.text("Event.observe(window, \"load\", function() {\n");

            e.text(_scriptBlock.toString());

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

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

    }
View Full Code Here

    private void addErrorClassToCurrentElement()
    {
        MarkupWriter writer = _environment.peekRequired(MarkupWriter.class);

        Element element = writer.getElement();

        addErrorClass(element);
    }
View Full Code Here

        _scriptBlock.append("\n");
    }

    public void updateDocument(Document document)
    {
        Element body = document.find("html/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", "language", "javascript");
            e.raw("\n<!--\n");

            e.text(_scriptBlock.toString());

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

    }
View Full Code Here

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);

        replay();

        Element e = writer.element("label", "accesskey", "f");

        ValidationDecorator decorator = new DefaultValidationDecorator(env, null, null, null);

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

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);

        replay();

        Element e = writer.element("label", "accesskey", "f", "class", "foo");

        ValidationDecorator decorator = new DefaultValidationDecorator(env, null, null, null);

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

     * @param link           the link that will form the href
     * @param namesAndValues additional attributes to write
     */
    protected 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

    @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

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.