[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-user
Subject:    Re: velocity runs method twice
From:       "Geir Magnusson Jr." <geirm () adeptra ! com>
Date:       2002-07-31 16:16:32
[Download RAW message or body]

On 7/31/02 1:46 PM, "Toasz Mielnik" <tomeasz.mielnik@tdcinternet.pl> wrote:

> hello all
> i'm workin on some project and i'm using velocity + servlets (with tomcat
> 4.1.7)
> i have errormsg class with method
> 
>   public Vector getMessage()
>   {
>       Vector v = (Vector) messages.clone ();
>       this.messages.clear();
> System.out.println ("DEBUG " +v);
>       return (v);
>   }
> 
> i have template also:
> 
> -----Error.vm------
> #parse("Header.vm")
> #parse("Footer.vm")
> ----- Header.vm-------
> <div align=center class=error>
> $errormsg.getMessage()
> </div>
> 
> When you look at the getMessage method you se that after geting messages main
> variable is cleared, so after second call the empty method returns null
> (assuming that there was only one message in Vector this.messages).
> THE PROBLEM IS that i see [] (empty brackets) on the page and my catalina.log
> says:
> DEBUG : [ example error message]
> DEBUG : []
> 
> So it looks for me as it's called twice
> My question is: Is Velocity calling this method twice or is it other problem?
> 

I does look like the template is getting rendered twice.

How about doing error.vm as

  Foo
  #parse("header.vm")
  

And see if you get two Foo's.

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic