Search in sources :

Example 1 with MarkupWriter

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

the class MarkupWriterFactoryImpl method constructMarkupWriter.

private MarkupWriter constructMarkupWriter(ContentType contentType, boolean partial, boolean HTML5) {
    final String mimeType = contentType.getMimeType();
    boolean isHTML = mimeType.equalsIgnoreCase("text/html");
    MarkupModel model;
    if (isHTML)
        model = HTML5 ? (partial ? html5PartialModel : html5Model) : (partial ? htmlPartialModel : htmlModel);
    else
        model = partial ? xmlPartialModel : xmlModel;
    return new MarkupWriterImpl(model, contentType.getCharset(), mimeType);
}
Also used : Html5MarkupModel(org.apache.tapestry5.dom.Html5MarkupModel) DefaultMarkupModel(org.apache.tapestry5.dom.DefaultMarkupModel) XMLMarkupModel(org.apache.tapestry5.dom.XMLMarkupModel) MarkupModel(org.apache.tapestry5.dom.MarkupModel)

Example 2 with MarkupWriter

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

the class MarkupWriterFactoryImpl method newMarkupWriter.

public MarkupWriter newMarkupWriter(Page page) {
    boolean isHTML5 = hasHTML5Doctype(page);
    ContentType contentType = pageContentTypeAnalyzer.findContentType(page);
    return constructMarkupWriter(contentType, false, isHTML5);
}
Also used : ContentType(org.apache.tapestry5.http.ContentType)

Example 3 with MarkupWriter

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

the class MarkupWriterFactoryImpl method newPartialMarkupWriter.

public MarkupWriter newPartialMarkupWriter(Page page) {
    boolean isHTML5 = hasHTML5Doctype(page);
    ContentType contentType = pageContentTypeAnalyzer.findContentType(page);
    return constructMarkupWriter(contentType, true, isHTML5);
}
Also used : ContentType(org.apache.tapestry5.http.ContentType)

Example 4 with MarkupWriter

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

the class RenderCommandComponentEventResultProcessor method renderMarkup.

/**
 * As a filter, this class does three things:
 * <ul>
 * <li>It creates an outer element to capture the partial page content that will be rendered</li>
 * <li>It does setup and cleanup with the {@link AjaxFormUpdateController}</li>
 * <li>It extracts the child markup and stuffs it into the reply's "content" property.</li>
 * </ul>
 */
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) {
    // 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");
    ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
    renderer.renderMarkup(writer, reply);
    ajaxFormUpdateController.cleanupAfterPartialZoneRender();
    writer.end();
    String content = root.getChildMarkup().trim();
    reply.put("content", content);
}
Also used : Element(org.apache.tapestry5.dom.Element)

Example 5 with MarkupWriter

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

the class CompositeRenderCommandTest method render_queue_commands_nyi.

@Test(dataProvider = "nyi_data")
public void render_queue_commands_nyi(RenderCommand rc) {
    MarkupWriter writer = mockMarkupWriter();
    RenderQueue queue = mockRenderQueue();
    try {
        new CompositeRenderCommand(new RenderCommand[] { rc }).render(writer, queue);
        unreachable();
    } catch (IllegalStateException ex) {
    // Don't care about the message.
    }
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) 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