velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <apa...@recks.org>
Subject Re: How to see if there is the end of the array
Date Fri, 22 Jul 2005 14:56:25 GMT
Checkout the IteratorTool which should address your request:

   http://jakarta.apache.org/velocity/tools/generic/

:) Christoph Reck


Jean Francois Chamard wrote:
> Christoph's simplest solution works perfectly :)
> but if you want to separate each column with , and the last one with 
> "and"... here is a way to do it
> Example: "java","perl","c++" and "xul"
> more complicated though
> 
> #set( $len = $column-detail-data.length )
> #foreach($column in $column-detail-data)
>    #set( $velocityCount2 = $velocityCount + 1 )
>    #set( $len2 = $len - 1 )
>    "${column.getChild("header").Text}"#if ($len2 == $velocityCount) 
> and#elseif ($len > $velocityCount2),#end
> #end
> 
> Jeff
> 
> Christoph Reck wrote:
> 
>> The simplest solution is to prefix the comma:
>>
>> #set( $sep = "" )
>> #foreach ($column in $column-detail-data)
>>
>>                    $sep"${column.getChild("header").Text}"
>>
>> #set( $sep = ", " )
>> #end
>>
>> This is fully independant of any counter and end of array.
>>
>> :) Christoph Reck
>>
>>
>> Minor, Vitali wrote:
>>
>>> Hallo,
>>>
>>>  
>>>
>>> I have question about the work with array.
>>>
>>> I have a #for-loop in my template like this:
>>>
>>>  
>>>
>>> #foreach ($column in $column-detail-data)
>>>
>>>                   "${column.getChild("header").Text}",
>>>
>>> #end
>>>
>>>  
>>>
>>> and I want to now if I'm on the end of the array $column,
>>>
>>> because of the comma at the end of the command.
>>>
>>>  
>>>
>>> If there is no more elements, I don't want to set comma any more.
>>>
>>>  
>>>
>>> Can you give me some advice please?
>>>
>>>  
>>>
>>> Thanks for reply.
>>>
>>>  
>>>
>>> Vitali
>>>
>>>
>>>
>>> ====================================================================
>>>  IPS Software GmbH
>>>  Isaac-Fulda-Allee 9
>>>  55124 Mainz
>>>  tel: +49.6131.37577.0
>>>  fax: +49.6131.37577.55
>>>  -
>>>  Niederlassung Munchen:
>>>  Grafinger Str. 2
>>>  81671 Munchen
>>>  tel.: +49.89.18926780
>>>  fax.: +49.89.18926808
>>>  -
>>>  url: http://www.ips-software.de
>>> ====================================================================
>>>  Diese e-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
>>>  Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
>>>  e-Mail irrtuemlich erhalten haben informieren Sie bitte sofort den
>>>  Absender und vernichten Sie diese e-Mail. Das unerlaubte Kopieren
>>>  sowie die unbefugte Weitergabe dieser e-Mail ist nicht gestattet.
>>> -
>>>  This e-mail contains confidential and/or proprietary information.
>>>  If you are not the intended recipient or if you received the e-Mail
>>>  by mistake we ask you to notify the sender immediately and destroy
>>>  this e-Mail. The unauthorized reproduction or distribution of this
>>>  e-Mail is prohibited.
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message