Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSLT and apache MultiKey Map

 
Carl Jenkins
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know in JSTL we can iterate over lists and maps, but is there a way to do the same for MultiKey maps?

 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean if the value of your map is another map or list ?

In that case just use another JSTL for each loop passing in the value of the current iteration of you root map.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about org.apache.commons.collections.map.MultiKeyMap, yes you can iterate over it with c:forEach, because it implements IterableMap, which is a subinterface of Map.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to prepare MultiKeyMap with MultiKey as a key. and to access it in jsp through JSTL/EL

I passed MultiKeyMap and Map(HashMap)<key(String in my case,Object of MultiKey)>

so it would be something like,



Christophe,
Initially I tried the same as I also thought it's same as any other map. But it accepts MultiKey as a key so I went for above approach. I don't know how can I use it as any other map.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The poster is asking about iterating it. So :

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic