private static String render(Renderable r) { HtmlCanvas c = new HtmlCanvas(); try { r.renderOn(c); } catch (IOException e) { e.printStackTrace(); } return c.toHtml(); }
/** * Render the component using the receiver. If available, prepare the * pageContext for accessing variables by the components. * * @param component a Renderable instance | null * @return the receiver this <code>HtmlCanvas</code> instance. * @throws IOException in case of an I/O error. */ public HtmlCanvas render(Renderable component) throws IOException { // Allow undefined component as argument. This is a noop. if (component == null) return this; if (pageContext != null) { pageContext.beginRender(); component.renderOn(this); pageContext.endRender(); } else { component.renderOn(this); } return this; } /**
private static String render(Renderable r) { HtmlCanvas c = new HtmlCanvas(); try { r.renderOn(c); } catch (IOException e) { e.printStackTrace(); } return c.toHtml(); }
public void renderOn(HtmlCanvas html) throws IOException {// @formatter:off // no need to inspect an exception if (target instanceof RenderException) { target.renderOn(html); return; } html .div(class_("rendersnake-inspector")) .write(target.getClass().getName()); html.getPageContext().renderForInpectorOn(this,html); target.renderOn(html); html._div(); } // @formatter:on
/** * Answer a pretty formatted HTML output for a Renderable component. * @param component * @return */ public static String toString(Renderable component) { HtmlCanvas html = new HtmlCanvas(new PrettyWriter()); try { component.renderOn(html); } catch (Exception ex){ throw new RuntimeException("Error writing HTML for component:" + component); } return html.toHtml(); }