Java – the trouble of iterating HashMap using JSF, myfaces, and facelets
I had some trouble looping through HashMap to print its values to the screen Someone can check my code carefully to see what I did wrong I can't seem to find any mistakes, but there must be something
In the servlet, I add the following to the request:
Map<String,String> facetValues = new HashMap<String,String>(); // Filling the map req.setAttribute(facetField.getName(),facetValues);
In one case, "facetfield. Getname()" is evaluated as "discipline" So in my page, I have the following content:
<ui:repeat value="${requestScope.discipline}" var="item"> <li>Item: <c:out value="${item}"/>,Key: <c:out value="${item.key}"/>,Value: <c:out value="${item.item}"/></li> </ui:repeat>
Loop runs once, but all outputs are blank?!? If it's more than a loop, I'll expect at least something in the project Check the facelets debug pop-up window, where the discipline is and loop Printing it to the screen will produce some maps that look like me (I shortened the output):
{300=0,1600=0,200=0,...,2200=0}
I also tried C: for each, but I got the same result So someone has any idea. Did I make a mistake?
Thank you for any comments, leeward
Solution
< UI: repeat > only accept list or datamodel, not sets or maps This is the roadmap for JSF 2.1