Interface Renderable

  • All Known Implementing Classes:
    Markup, ResponseChunks, ServerSentEvents

    public interface Renderable
    A renderable object, that can be given to Context.render(Object).

    A Renderer for this type is provided by Ratpack core, that simply delegates to render(Context). An alternative to providing a Renderer implementation for a type is to make the type implement this interface.

     import ratpack.handling.Context;
     import ratpack.render.Renderable;
     import ratpack.test.embed.EmbeddedApp;
     import static org.junit.Assert.*;
     public class Example {
       static class Thing implements Renderable {
         public void render(Context context) {
       static void main(String... args) throws Exception {
         EmbeddedApp.fromHandler(ctx ->
           ctx.render(new Thing())
         ).test(httpClient ->
           assertEquals("thing!", httpClient.getText())

    An alternative to making a type implement this interface, is implementing a Renderer for it.

    • Method Detail

      • render

        void render​(Context context)
             throws java.lang.Exception
        Render this object to the response.
        context - the request handling context
        java.lang.Exception - any