You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by dick_hu <di...@gmail.com> on 2011/07/15 08:27:09 UTC

Loop Map

How can I Loop the Map?
in the loop I can get the key and value.
Can anyone share a part of code?
Thanks a lot.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Loop-Map-tp4589569p4589569.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Loop Map

Posted by "dragan.sahpaskix@gmail.com" <dr...@gmail.com>.
Here is a short example:

TML (not tested)
<t:loop source="keys" value="key">

key: ${key}  -   value: ${value}

</t:loop>

JAVA (not tested)

private Map<String, String> map;

public Collection<String> getKeys(){

return map.keyset();

}

@Property
private String key;

public String getValue(){

return map.get(key);

}

Cheers,
Dragan Sahpaski



On Fri, Jul 15, 2011 at 8:27 AM, dick_hu <di...@gmail.com> wrote:

> How can I Loop the Map?
> in the loop I can get the key and value.
> Can anyone share a part of code?
> Thanks a lot.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Loop-Map-tp4589569p4589569.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Loop Map

Posted by Robert Zeigler <ro...@roxanemy.com>.
How about iterating over the entry set? 

.java
  @Property
  private Map.Entry entry;

<t:loop source="map.entrySet()" value="entry">
    ${entry.key}: ${entry.value}
</t:loop>

Robert
  
On Jul 15, 2011, at 7/151:27 AM , dick_hu wrote:

> How can I Loop the Map?
> in the loop I can get the key and value.
> Can anyone share a part of code?
> Thanks a lot.
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Loop-Map-tp4589569p4589569.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Loop Map

Posted by dick_hu <di...@gmail.com>.
Thank you,they are helpful to me.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Loop-Map-tp4589569p4589722.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org