From: Tim P. <ti...@pa...> - 2004-02-28 01:34:43
|
On Friday 27 February 2004 11:05 pm, Brian Goetz wrote: > >The problem seems to be that org.webmacro.Template no longer > >renders to a FastWriter but to an OutputStream, which breaks > >my rendering to a string buffer, as a StringWriter does not have > >an OutputStream ???? > > Template can also render directly to a String. I am getting IllegalStateException from the following public class WebmacroTemplate implements Template { private org.webmacro.Template template; public WebmacroTemplate(org.webmacro.Template t) { template =3D t; } /** * @param out A {@link MelatiWebmacroWriter}. */ public void write(MelatiWriter out, TemplateContext templateContext,=20 TemplateEngine engine) throws TemplateEngineException= { try { WebContext wc =3D (WebContext)templateContext.getContext(); if (out instanceof MelatiStringWriter) { String o =3D template.evaluateAsString(wc); wc.getResponse().getWriter().write(o); } else { OutputStream o =3D ((MelatiWebmacroWriter)out).getOutputStream();= =20 template.write(o, wc); } } catch (ContextException e) { throw new TemplateEngineException(e); } catch (IOException e) { throw new TemplateEngineException(e); } } } going to bed, my eyes hurt Tim Pizey |