Christoph Reck wrote:
>
> Please put the pop int a finally block. The render() has not been
> suficiently protected in the past to avoid exceptions. I see
> that the ica is not reused so it really wouldn't matter, but who
> knows, this might change...
>
> vp.render( ica, writer, null);
> - ica.popCurrentTemplateName();
> + }
> + finally
> + {
> + ica.popCurrentTemplateName();
> + }
> catch (Exception e )
That's a better catch than you think :) [ I meant to do that ... see
Template :) ]
Because the template name stack *isn't* really in the ica - it's in the
baseclass InternalContextBase of VelocityContext... (via
AbstractContext), so this would have accumulated... probably no harm,
but not right either.
Good one.
geir
> :) Christoph
>
> [EMAIL PROTECTED] wrote:
> >
> > geirm 01/02/04 20:42:23
> >
> > Modified: whiteboard/geir Velocity.java
> > Log:
> > Change b/c the internal context changed for template name tracking...
> >
> > Revision Changes Path
> > 1.3 +4 -3 jakarta-velocity/whiteboard/geir/Velocity.java
> >
> > Index: Velocity.java
> > ===================================================================
> > RCS file: /home/cvs/jakarta-velocity/whiteboard/geir/Velocity.java,v
> > retrieving revision 1.2
> > retrieving revision 1.3
> > diff -u -r1.2 -r1.3
> > --- Velocity.java 2001/02/02 11:57:56 1.2
> > +++ Velocity.java 2001/02/05 04:42:23 1.3
> > @@ -65,7 +65,7 @@
> > * SLOW PROGRESS :)
> > *
> > * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
> > - * @version $Id: Velocity.java,v 1.2 2001/02/02 11:57:56 geirm Exp $
> > + * @version $Id: Velocity.java,v 1.3 2001/02/05 04:42:23 geirm Exp $
> > */
> >
> > package org.apache.velocity.util;
> > @@ -180,9 +180,10 @@
> > if (nodeTree != null)
> > {
> > InternalContextAdapterImpl ica = new
>InternalContextAdapterImpl( context );
> > - ica.setCurrentTemplateName( logTag );
> > + ica.pushCurrentTemplateName( logTag );
> > nodeTree.init( ica, null );
> > nodeTree.render( ica, writer );
> > + ica.popCurrentTemplateName();
> > return true;
> > }
> > }
> > @@ -275,9 +276,9 @@
> > {
> > InternalContextAdapterImpl ica = new InternalContextAdapterImpl(
>context );
> >
> > - ica.setCurrentTemplateName( namespace );
> > -
> > + ica.pushCurrentTemplateName( namespace );
> > vp.render( ica, writer, null);
> > + ica.popCurrentTemplateName();
> > }
> > catch (Exception e )
> > {
> >
> >
> >
>
> --
> ==============================================================
> Deutsches Zentrum fuer Luft- und Raumfahrt (DLR)
> Deutsches Fernerkundungs Datenzentrum (DFD)
> DLR-DFD, Muenchner Strasse 20, D-82234 Wessling, Germany
> ============= Currenlty relocated to ESA-ESRIN ===============
> ESA ESRIN Tel: +39 06 941 80 589
> c/o Christoph Reck (DLR) Fax: +39 06 941 80 512
> Via Galileo Galilei mailto:[EMAIL PROTECTED]
> I-00044 Frascati (Roma) http://www.dfd.dlr.de
> ==============================================================
--
Geir Magnusson Jr. [EMAIL PROTECTED]
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity