public static String renderWithTransformToHTML ( final Request request , final WComponent component , final boolean includePageShell ) { // Setup a context (if needed) boolean needsContext = UIContextHolder . getCurrent ( ) == null ; if ( needsContext ) { UIContextHolder . pushContext ( new UIContextImpl ( ) ) ; } try { // Link Interceptors InterceptorComponent templateRender = new TemplateRenderInterceptor ( ) ; InterceptorComponent transformXML = new TransformXMLInterceptor ( ) ; templateRender . setBackingComponent ( transformXML ) ; if ( includePageShell ) { transformXML . setBackingComponent ( new PageShellInterceptor ( ) ) ; } // Attach Component and Mock Response InterceptorComponent chain = templateRender ; chain . attachUI ( component ) ; chain . attachResponse ( new MockResponse ( ) ) ; // Render chain StringWriter buffer = new StringWriter ( ) ; chain . preparePaint ( request ) ; try ( PrintWriter writer = new PrintWriter ( buffer ) ) { chain . paint ( new WebXmlRenderContext ( writer ) ) ; } return buffer . toString ( ) ; } finally { if ( needsContext ) { UIContextHolder . popContext ( ) ; } } }
Renders and transforms the given WComponent to a HTML String outside of the context of a Servlet .