You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Carlo Torniai <ca...@hp.com> on 2006/06/28 15:14:23 UTC
Chhecking Vector content from template
Hi all.
I'm trying to evaluate if a vector contains elements from my template.
The vector is added at the context in this way from my Servlet.
ctx.put("frontrightpic", front_right_pict);
I'm able to retrieve content in the template using
#foreach ($photo_front_right in $frontrightpic)
I want to check if the vector contains any result in order to change the
displayed HTML.
I've tried to use
#if($photo_front_right=='')
and also other conditions on $frontrightpic don't seem to work.
Can you help me to check if vector contains any entry?
Thanks.
Carlo
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Chhecking Vector content from template
Posted by Carlo Torniai <ca...@hp.com>.
Yes I'm trying to detect empty vector.
Usage of #foreach confused me.
Now everything works fine.
Thanks
Carlo
Joe Desbonnet wrote:
> I'm not clear about what you want to do. Are you trying to detect an
> empty Vector?
>
> You can call the size() method on the java.util.Vector object to get
> the number of elements. So ($myVec.size() == 0) will be true for
> Vectors with no elements.
>
> Joe
>
>
> On 6/28/06, Carlo Torniai <ca...@hp.com> wrote:
>> Hi all.
>> I'm trying to evaluate if a vector contains elements from my template.
>>
>> The vector is added at the context in this way from my Servlet.
>>
>> ctx.put("frontrightpic", front_right_pict);
>>
>> I'm able to retrieve content in the template using
>>
>> #foreach ($photo_front_right in $frontrightpic)
>>
>> I want to check if the vector contains any result in order to change the
>> displayed HTML.
>> I've tried to use
>> #if($photo_front_right=='')
>>
>> and also other conditions on $frontrightpic don't seem to work.
>>
>> Can you help me to check if vector contains any entry?
>> Thanks.
>> Carlo
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Chhecking Vector content from template
Posted by Joe Desbonnet <jd...@gmail.com>.
I'm not clear about what you want to do. Are you trying to detect an
empty Vector?
You can call the size() method on the java.util.Vector object to get
the number of elements. So ($myVec.size() == 0) will be true for
Vectors with no elements.
Joe
On 6/28/06, Carlo Torniai <ca...@hp.com> wrote:
> Hi all.
> I'm trying to evaluate if a vector contains elements from my template.
>
> The vector is added at the context in this way from my Servlet.
>
> ctx.put("frontrightpic", front_right_pict);
>
> I'm able to retrieve content in the template using
>
> #foreach ($photo_front_right in $frontrightpic)
>
> I want to check if the vector contains any result in order to change the
> displayed HTML.
> I've tried to use
> #if($photo_front_right=='')
>
> and also other conditions on $frontrightpic don't seem to work.
>
> Can you help me to check if vector contains any entry?
> Thanks.
> Carlo
>
>
>
> ---------------------------------------------------------------------
> 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