HashMap Issues with JSF, MyFaces & Facelets

I am having trouble interleaving a HashMap to print its values ​​on screen. Can someone double check my code to see what I am doing wrong. I can’t find anything bad, 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 ()" evaluates to "discipline." So on 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 cycle is executed once, but all outputs are empty?!? I would at least expect something in the element if it went through the loop at a time. Checking the debug popup for Facelets, there is discipline in the loop too. Printing on the screen leads to what looks like a map for me (I reduced the output):

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

c: forEach, . - , ?

,

+3
3

<ui:repeat> List DataModel, . JSF 2.1.

+10

el 2.2 , .

<ui:repeat value="#{myBean.stats.keySet().toArray()}" var="x">
    <h:outputText value="#{myBean.stats.get(x)}" /><br />
</ui:repeat>
+12

:

1.

ui: repeat ( List), , UIRepeat DataModel ( h: dataTable). DataModel - . DataModel, (, java.util.List).

2.

, :

${item}
${item.key}
${item.item}

"" List < Map.Entry < String, String > gt;, :

${item.key}
${item.value}

:

Map<String, String> facetValues = new HashMap<String, String>();
// Filling the map
List<Map.Entry<String, String>> discipline
        = new ArrayList<Map.Entry<String, String>>(facetValues.entrySet());

3.

FAQ , JSTL . , c: out ui: repeat . , h: outputText. ( , , .)


- JSF, , , !

+1

Source: https://habr.com/ru/post/1708173/


All Articles