commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Walters <walt...@edge.net>
Subject Re: core:forEach collections
Date Tue, 16 Dec 2003 00:12:04 GMT
I took a quick look at the forEach tag code from 
org.apache.commons.jelly.tags.core and I think this is the part where it 
figures out to do with your items parameter...

 From the evaluateAsIterator function in 
org.apache.commons.jelly.expression.ExpressionSupport


if ( value instanceof Iterator ) {
     return (Iterator) value;
}
else if ( value instanceof List ) {
     List list = (List) value;
     return list.iterator();
}
else if ( value instanceof Map ) {
     Map map = (Map) value;
     return map.entrySet().iterator();
}
else if ( value.getClass().isArray() ) {
     return new ArrayIterator( value );
}
else if ( value instanceof Enumeration ) {
     return new EnumerationIterator((Enumeration ) value);
}
else if ( value instanceof Collection ) {
   Collection collection = (Collection) value;
   return collection.iterator();


To use a comma delimited list, you would have to parse it into an array 
first with something like the split function from the java.lang.String 
class.


Scott


Amnon Khen wrote:
> Hi all,
> I sent a question about jelly core:forEcah collection almost a week ago and
> no one has answered me.
> Is my question off-topic? Is it a newbie question? I tried looking up the
> answer myself before posting a message here and haven't found anything...
> Please help... :)
> Thanks,
> 	Amnon
> 
> ______________________________________________________________________
> Amnon Khen, Configuration Management, Cash-U Mobile Technologies LTD. 
> Mobile: +972-(0)54-922394 / Office: +972-(0)9-8920815
> mailto:amnon.khen@cash-u.com / http://www.cash-u.com
> Israel - 45 Hamelacha St., P.O. Box 8617, New Industrial Zone, Netanya
> 36880, Israel / Tel: +972 9 8920888 
> Europe - Argentum, 2 Queen Caroline St., Hammersmith, London W6 9DT, UK /
> Tel: +44 20 8323 8066
> Asia-Pacific -  47A Duxton Road, Singapore 089511 / Tel: +65 67322440
> ______________________________________________________________________
> This e-mail message and its attachments are for the sole use of the intended
> recipient(s), may contain confidential and/or privileged information and are
> to  be regarded as confidential information under any non disclosure
> agreement. Any review, use, disclosure or distribution by persons or
> entities other than the intended recipient(s) is prohibited. If you are not
> the intended recipient, please contact the  sender by reply and destroy all
> copies of the original message and its attachments.
> ______________________________________________________________________
> 
> 
> -----Original Message-----
> From: Amnon Khen [mailto:amnon.khen@cash-u.com] 
> Sent: Tuesday, December 09, 2003 17:49
> To: 'commons-user@jakarta.apache.org'
> Subject: core:forEach collections
> 
> Hi Jelly folk,
> What types of collections can be used in the core:forEach tag?
> In the ForEach task from ant-contrib, one can use delimited strings as well
> as Ant data types like Path-like Structures. Can this also be simply
> achieved in Jelly?
> I'm thinking about something in the neighborhood of:
> <c:forEach ...>
>             <c:list>
>                         ...
>             </c:list>
> </c:forEach>
> I can always create a path and convert it into a delimited string the
> PathConvert task, but it's a bit tedious. It won't kill me, of course...
> Is there a way to group properties in to a set similarly to the PropertySet
> data type in Ant 1.6?
> Thanks for your time and consideration,
>             Amnon
> ______________________________________________________________________
> Amnon Khen, Configuration Management, Cash-U Mobile Technologies LTD. 
> Mobile: +972-(0)54-922394 / Office: +972-(0)9-8920815
> mailto:amnon.khen@cash-u.com <mailto:amnon.khen@cash-u.com>  /
> http://www.cash-u.com <http://www.cash-u.com/> 
> Israel - 45 Hamelacha St., P.O. Box 8617, New Industrial Zone, Netanya
> 36880, Israel / Tel: +972 9 8920888 
> Europe - Argentum, 2 Queen Caroline St., Hammersmith, London W6 9DT, UK /
> Tel: +44 20 8323 8066
> Asia-Pacific -  47A Duxton Road, Singapore 089511 / Tel: +65 67322440
> ______________________________________________________________________
> This e-mail message and its attachments are for the sole use of the intended
> recipient(s), may contain confidential and/or privileged information and are
> to  be regarded as confidential information under any non disclosure
> agreement. Any review, use, disclosure or distribution by persons or
> entities other than the intended recipient(s) is prohibited. If you are not
> the intended recipient, please contact the  sender by reply and destroy all
> copies of the original message and its attachments.
> ______________________________________________________________________
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message