public static String render ( final Request request , final WComponent component ) { boolean needsContext = UIContextHolder . getCurrent ( ) == null ; if ( needsContext ) { UIContextHolder . pushContext ( new UIContextImpl ( ) ) ; } try { StringWriter buffer = new StringWriter ( ) ; component . preparePaint ( request ) ; try ( PrintWriter writer = new PrintWriter ( buffer ) ) { component . paint ( new WebXmlRenderContext ( writer ) ) ; } return buffer . toString ( ) ; } finally { if ( needsContext ) { UIContextHolder . popContext ( ) ; } } }
Renders the given WComponent to a String outside of the context of a Servlet . This is good for getting hold of the XML for debugging unit testing etc . Also it is good for using the WComponent framework as a more generic templating framework .