@ Override public void paint ( final RenderContext renderContext ) { if ( ! ( renderContext instanceof WebXmlRenderContext ) ) { throw new SystemException ( "Unable to render to " + renderContext ) ; } PrintWriter writer = ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ; Template template = null ; try { template = VelocityEngineFactory . getVelocityEngine ( ) . getTemplate ( templateUrl ) ; } catch ( Exception ex ) { String message = "Could not open velocity template \"" + templateUrl + "\" for \"" + this . getClass ( ) . getName ( ) + "\"" ; LOG . error ( message , ex ) ; writer . println ( message ) ; return ; } try { VelocityContext context = new VelocityContext ( ) ; fillContext ( context ) ; template . merge ( context , writer ) ; } catch ( ResourceNotFoundException rnfe ) { LOG . error ( "Could not find template " + templateUrl , rnfe ) ; } catch ( ParseErrorException pee ) { // syntax error : problem parsing the template LOG . error ( "Parse problems" , pee ) ; } catch ( MethodInvocationException mie ) { // something invoked in the template // threw an exception Throwable wrapped = mie . getWrappedThrowable ( ) ; LOG . error ( "Problems with velocity" , mie ) ; if ( wrapped != null ) { LOG . error ( "Wrapped exception..." , wrapped ) ; } } catch ( Exception e ) { LOG . error ( "Problems with velocity" , e ) ; } }
Renders the component using the velocity template which has been provided .