Package org.apache.tapestry

Examples of org.apache.tapestry.MarkupWriter


        Select select = new Select();

        select.setModel(new SelectModelImpl(null, options));
        select.setValue("barney");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("option_attributes.html"));
    }
View Full Code Here


        Select select = new Select();

        select.setModel(new SelectModelImpl(null, options));
        select.setValue("barney");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("disabled_option.html"));

    }
View Full Code Here

        Select select = new Select();

        select.setModel(new SelectModelImpl(groupModels, null));
        select.setValue("Fred");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("option_groups.html"));
    }
View Full Code Here

        select.setModel(new SelectModelImpl(Collections.singletonList(husbands), TapestryUtils
                .toOptionModels("Wilma,Betty")));
        select.setValue("Fred");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("option_groups_precede_ungroup_options.html"));
    }
View Full Code Here

        Select select = new Select();

        select.setModel(new SelectModelImpl(Collections.singletonList(husbands), null));
        select.setValue("Fred");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("option_group_attributes.html"));
    }
View Full Code Here

        return tracker.inError(field);
    }

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

        Element element = writer.getElement();

        addErrorClass(element);
    }
View Full Code Here

    }

    @Test
    public void label_error_no_existing_class_attribute()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

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

        replay();

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

        ValidationDecorator decorator = new DefaultValidationDecorator(env);

        decorator.insideLabel(field, e);

        assertEquals(writer.toString(), "<label accesskey=\"f\" class=\"t-error\"/>");

        verify();
    }
View Full Code Here

    }

    @Test
    public void label_error_with_existing_class_attribute()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

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

        decorator.insideLabel(field, e);

        assertEquals(writer.toString(), "<label accesskey=\"f\" class=\"foo t-error\"/>");

        verify();
    }
View Full Code Here

    }

    @Test
    public void field_error()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

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

        replay();

        writer.element(
                "input",
                "type",
                "text",
                "name",
                "ex",
                "class",
                "foo",
                "value",
                "freddy",
                "size",
                "30");

        ValidationDecorator decorator = new DefaultValidationDecorator(env);

        decorator.insideField(field);

        assertEquals(
                writer.toString(),
                "<input class=\"foo t-error\" name=\"ex\" size=\"30\" type=\"text\" value=\"freddy\"/>");

        verify();
    }
View Full Code Here

public class MarkupWriterImplTest extends InternalBaseTestCase
{
    @Test(expectedExceptions = IllegalStateException.class)
    public void write_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.write("fail!");
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.MarkupWriter

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.