Troubles Iterating Over A HashMap with JSF, MyFaces & Facelets

Posted by Lee Theobald on Stack Overflow See other posts from Stack Overflow or by Lee Theobald
Published on 2009-05-12T12:34:11Z Indexed on 2010/05/01 8:07 UTC
Read the original article Hit count: 448

Filed under:
|
|
|

Hi all,

I'm having some trouble looping over a HashMap to print out it's values to the screen. Could someone double check my code to see what I'm doing wrong. I can't seem to find anything wrong but there must be something.

In a servlet, I am adding 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()" evaluates to "discipline". So in my page I have the following:

<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>

The loop is ran once but all the outputs are blank?!? I would have at least expected something in item if it's gone over the loop once. Checking the debug popup for Facelets, discipline is there and on the loop. Printing it to the screen results in something that looks like a map to me (I've shortened the output) :

{300=0, 1600=0, 200=0, ... , 2200=0}

I've also tried with a c:forEach but I'm getting the same results. So does anyone have any ideas where I'm going wrong?

Thanks for any input, Lee

© Stack Overflow or respective owner

Related posts about facelets

Related posts about myfaces