Search in sources :

Example 6 with MarkupWriter

use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.

the class UploadTest method begin_render_writes_input_tag.

@Test
public void begin_render_writes_input_tag() throws Exception {
    MarkupWriter writer = createMarkupWriter();
    writer.element("form");
    FormSupport formSupport = mockFormSupport();
    ComponentResources resources = mockComponentResources();
    FieldValidator validator = mockFieldValidator();
    Request request = mockRequest();
    train_isXHR(request, false);
    formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
    validator.render(writer);
    resources.renderInformalParameters(writer);
    replay();
    Upload component = new Upload(null, null, null, null, resources, null);
    component.injectDecorator(new BaseValidationDecorator()).injectFormSupport(formSupport).injectFieldValidator(validator).injectRequest(request);
    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();
}
Also used : Element(org.apache.tapestry5.dom.Element) Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) Test(org.testng.annotations.Test)

Example 7 with MarkupWriter

use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.

the class UploadTest method validation_decorator_invoked_inside_begin_render.

@Test
public void validation_decorator_invoked_inside_begin_render() throws Exception {
    getMocksControl().checkOrder(true);
    ComponentResources resources = mockComponentResources();
    Upload component = new Upload(null, null, null, null, resources, null);
    MarkupWriter writer = createMarkupWriter();
    writer.element("form");
    FieldValidator validator = mockFieldValidator();
    Request request = mockRequest();
    FormSupport formSupport = mockFormSupport();
    formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
    component.injectFormSupport(formSupport).injectRequest(request);
    ValidationDecorator decorator = mockValidationDecorator();
    component.injectDecorator(decorator).injectFieldValidator(validator);
    validator.render(writer);
    resources.renderInformalParameters(writer);
    decorator.insideField(component);
    train_isXHR(request, false);
    replay();
    component.beginRender(writer);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) Test(org.testng.annotations.Test)

Example 8 with MarkupWriter

use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.

the class ComponentResourcesRenderer method render.

public void render(ComponentResources object, MarkupWriter writer) {
    writer.writef("%s (class %s)", object.getCompleteId(), object.getComponentModel().getComponentClassName());
    Location location = object.getLocation();
    if (location != null) {
        writer.element("br");
        writer.end();
        masterRenderer.render(location, writer);
    }
}
Also used : Location(org.apache.tapestry5.commons.Location)

Example 9 with MarkupWriter

use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.

the class OutputRawTest method value_is_non_blank.

@Test
public void value_is_non_blank() {
    String value = " ";
    MarkupWriter writer = mockMarkupWriter();
    writer.writeRaw(value);
    replay();
    OutputRaw component = new OutputRaw();
    component.setValue(value);
    assertFalse(component.beginRender(writer));
    verify();
}
Also used : MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 10 with MarkupWriter

use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.

the class OutputTest method output_with_element_and_informals.

@Test
public void output_with_element_and_informals() {
    String elementName = "span";
    MarkupWriter writer = createMarkupWriter();
    ComponentResources resources = mockComponentResources();
    train_renderInformalParameters(resources, writer, "foo", "bar");
    replay();
    Output component = new Output();
    component.setup(value, format, true, elementName, resources);
    assertFalse(component.beginRender(writer));
    verify();
    assertEquals(writer.toString(), "<span foo=\"bar\">22.70</span>");
}
Also used : MarkupWriter(org.apache.tapestry5.MarkupWriter) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Aggregations

MarkupWriter (org.apache.tapestry5.MarkupWriter)72 Test (org.testng.annotations.Test)69 Element (org.apache.tapestry5.dom.Element)21 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)19 MarkupWriterImpl (org.apache.tapestry5.internal.services.MarkupWriterImpl)16 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)14 RenderQueue (org.apache.tapestry5.runtime.RenderQueue)14 ComponentResources (org.apache.tapestry5.ComponentResources)13 Link (org.apache.tapestry5.http.Link)11 SelectModelImpl (org.apache.tapestry5.internal.SelectModelImpl)9 StringValueEncoder (org.apache.tapestry5.internal.services.StringValueEncoder)9 FormSupport (org.apache.tapestry5.services.FormSupport)9 JSONObject (org.apache.tapestry5.json.JSONObject)7 PartialMarkupRenderer (org.apache.tapestry5.services.PartialMarkupRenderer)6 PartialMarkupRendererFilter (org.apache.tapestry5.services.PartialMarkupRendererFilter)6 Map (java.util.Map)5 FieldTranslator (org.apache.tapestry5.FieldTranslator)5 Translator (org.apache.tapestry5.Translator)5 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)5 Messages (org.apache.tapestry5.commons.Messages)5