You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Hans Prueller <ha...@gmx.net> on 2004/01/22 14:01:12 UTC
how to get rid of multiple-used iterators???
hi there,
i am displaying a list objects in a velocity template. for each iteration
(each object) I call
#parse(templatename.vm) to render a set of possible commands available for
that object...
now i get the warning
WARN : IMSAppServ.logVelocityMessage : Warning! The reference $cmd is an
Iterato
r in the #foreach() loop at [70,17] in template common/cmd.vm. Because it's
not
resetable, if used in more than once, this may lead to unexpected results.
How can I get rid of that?
thanks in advance,
hans
Re: AW: how to get rid of multiple-used iterators???
Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Jan 22, 2004, at 10:33 AM, Hans Prueller wrote:
> hi geir!
>
> thank you for the tip... it just helped me start thinking ;-)
> the problem was that $cmd was set by a Hashtable.keys() call
>
> - now I use Hashtable.keySet() and the warning's gone!
Yep - that's a collection and Vel will dig out the iterator() from it
repeatedly...
>
> hans
>
> -----Ursprüngliche Nachricht-----
> Von: Geir Magnusson Jr [mailto:geir@4quarters.com]
> Gesendet: Donnerstag, 22. Jänner 2004 15:24
> An: Velocity Users List
> Betreff: Re: how to get rid of multiple-used iterators???
>
>
>
> On Jan 22, 2004, at 8:01 AM, Hans Prueller wrote:
>
>> hi there,
>>
>> i am displaying a list objects in a velocity template. for each
>> iteration
>> (each object) I call
>>
>> #parse(templatename.vm) to render a set of possible commands available
>> for
>> that object...
>>
>> now i get the warning
>>
>> WARN : IMSAppServ.logVelocityMessage : Warning! The reference $cmd is
>> an
>> Iterato
>> r in the #foreach() loop at [70,17] in template common/cmd.vm. Because
>> it's
>> not
>> resetable, if used in more than once, this may lead to unexpected
>> results.
>>
>> How can I get rid of that?
>
> Get rid of the warning? Right now, you can't. It's there to make sure
> that you don't do :
>
>
> #foreach($element in $cmd)
> ....
> #end
>
> <other stuff>
>
> #foreach($element in $cmd)
> ...
> #end
>
>
> because the Iterator can't be reset. To make sure that there's no
> danger in reuse, can you make $cmd something other than an iterator? A
> list, maybe? Or a general Collection?
>
>>
>> thanks in advance,
>> hans
>>
> --
> Geir Magnusson Jr 203-247-1713(m)
> geir@4quarters.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
--
Geir Magnusson Jr 203-247-1713(m)
geir@4quarters.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
AW: how to get rid of multiple-used iterators???
Posted by Hans Prueller <ha...@gmx.net>.
hi geir!
thank you for the tip... it just helped me start thinking ;-)
the problem was that $cmd was set by a Hashtable.keys() call
- now I use Hashtable.keySet() and the warning's gone!
hans
-----Ursprüngliche Nachricht-----
Von: Geir Magnusson Jr [mailto:geir@4quarters.com]
Gesendet: Donnerstag, 22. Jänner 2004 15:24
An: Velocity Users List
Betreff: Re: how to get rid of multiple-used iterators???
On Jan 22, 2004, at 8:01 AM, Hans Prueller wrote:
> hi there,
>
> i am displaying a list objects in a velocity template. for each
> iteration
> (each object) I call
>
> #parse(templatename.vm) to render a set of possible commands available
> for
> that object...
>
> now i get the warning
>
> WARN : IMSAppServ.logVelocityMessage : Warning! The reference $cmd is
> an
> Iterato
> r in the #foreach() loop at [70,17] in template common/cmd.vm. Because
> it's
> not
> resetable, if used in more than once, this may lead to unexpected
> results.
>
> How can I get rid of that?
Get rid of the warning? Right now, you can't. It's there to make sure
that you don't do :
#foreach($element in $cmd)
....
#end
<other stuff>
#foreach($element in $cmd)
...
#end
because the Iterator can't be reset. To make sure that there's no
danger in reuse, can you make $cmd something other than an iterator? A
list, maybe? Or a general Collection?
>
> thanks in advance,
> hans
>
--
Geir Magnusson Jr 203-247-1713(m)
geir@4quarters.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: how to get rid of multiple-used iterators???
Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Jan 22, 2004, at 8:01 AM, Hans Prueller wrote:
> hi there,
>
> i am displaying a list objects in a velocity template. for each
> iteration
> (each object) I call
>
> #parse(templatename.vm) to render a set of possible commands available
> for
> that object...
>
> now i get the warning
>
> WARN : IMSAppServ.logVelocityMessage : Warning! The reference $cmd is
> an
> Iterato
> r in the #foreach() loop at [70,17] in template common/cmd.vm. Because
> it's
> not
> resetable, if used in more than once, this may lead to unexpected
> results.
>
> How can I get rid of that?
Get rid of the warning? Right now, you can't. It's there to make sure
that you don't do :
#foreach($element in $cmd)
....
#end
<other stuff>
#foreach($element in $cmd)
...
#end
because the Iterator can't be reset. To make sure that there's no
danger in reuse, can you make $cmd something other than an iterator? A
list, maybe? Or a general Collection?
>
> thanks in advance,
> hans
>
--
Geir Magnusson Jr 203-247-1713(m)
geir@4quarters.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org