You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Bill Keese <bi...@tech.beacon-it.co.jp> on 2003/05/23 02:14:10 UTC
[jelly] cvs commit: jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl DynamicTag.java
Bob,
This checkin looks interesting but I'm not sure I understand it. Can I use
it to iterate over the arguments to a user defined tag, like C's varargs?
Something like this?
<define:tag name="myVarArgsTag">
<core:forEach var="arg" items="${attrs}">
<x>argument is ${arg.getKey()} is ${arg.getValue()}</x>
</core:forEach>
</define:tag>
Or is it something different? By the way, if I wrote some documentation
about variable handling in jelly, is there a way to add it to the website?
Bill
----- Original Message -----
From: <we...@apache.org>
To: <ja...@apache.org>
Sent: Friday, May 23, 2003 7:25 AM
Subject: cvs commit:
jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl DynamicTag.java
> werken 2003/05/22 15:25:33
>
> Modified: jelly/src/java/org/apache/commons/jelly/impl
DynamicTag.java
> Log:
> Exposing dynamic tag attributes Map as ${attrs}
>
> Revision Changes Path
> 1.7 +12 -0
jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl/DynamicTag.java
>
> Index: DynamicTag.java
> ===================================================================
> RCS file:
/home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl/Dynam
icTag.java,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -r1.6 -r1.7
> --- DynamicTag.java 10 Mar 2003 13:00:51 -0000 1.6
> +++ DynamicTag.java 22 May 2003 22:25:33 -0000 1.7
> @@ -63,6 +63,7 @@
>
> import java.util.HashMap;
> import java.util.Map;
> +import java.util.Iterator;
>
> import org.apache.commons.jelly.DynaTagSupport;
> import org.apache.commons.jelly.JellyContext;
> @@ -110,6 +111,17 @@
>
> // create new context based on current attributes
> JellyContext newJellyContext =
context.newJellyContext(attributes);
> + Map attrMap = new HashMap();
> + for ( Iterator keyIter = this.attributes.keySet().iterator();
> + keyIter.hasNext();) {
> + String key = (String) keyIter.next();
> + if ( key.endsWith( "Attr" ) ) {
> + Object value = this.attributes.get( key );
> + attrMap.put( key, value );
> + attrMap.put( key.substring( 0, key.length()-4 ),
value );
> + }
> + }
> + newJellyContext.setVariable( "attrs", attrMap );
> getTemplate().run(newJellyContext, output);
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org