I’ve a Map in a bean as follows:
public class TaskListData {
private Map<String, String[]> srcMasks = new HashMap<String, String[]>();
private Map<Integer, Map<String, String[]>> ftqSet = new HashMap<Integer, Map<String, String[]>>();
public void setFTQSet(Integer ftqid, String[] src, String[] masks) {
srcMasks.put("srcDir", src);
srcMasks.put("masks", masks);
ftqSet.put(ftqid, srcMasks);
}
This ftqSet fits in below datastructure:
feedId = "5",
feedName = "myFeedName",
ftqSet => {
1 => {
srcDirs = ["/path/string"],
masks = ["p.txt", "q.csv"]
}
2 => { ...
}
}, ...
In my test JSP file I’ve been trying to access the data using <c:forEach>:
<c:forEach items="#{bean.ftqSet}" var="f">
this text does not print
${f.feedId}
</c:forEach>
But it’s not outputting ${f.feedId}. Why would this be? How would I access this structure’s individual elements so I can create a nice table?
Each iteration of
Mapin ac:forEachgives aMap.Entryinstance which in turn hasgetKey()andgetValue()methods. It’s similar to doingfor (Entry entry : map.entrySet())in plain Java.E.g.
In case of a
Map<Integer, Map<String, String[]>>the#{entry.value}returns aMap<String, String[]>, so you need to iterate over it as well:But in your case, the
#{nestedentry.value}is actually aString[], so we need to iterate over it again:By the way, this ought to work with
rich:dataListas well.