使用JSF,MyFaces& amp; Facelets的 [英] Troubles Iterating Over A HashMap with JSF, MyFaces & Facelets

查看:166
本文介绍了使用JSF,MyFaces& amp; Facelets的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在循环HashMap以将其值打印到屏幕时遇到了一些麻烦。有人可以仔细检查我的代码,看看我做错了什么。我似乎找不到任何错误,但必须有一些东西。

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.

在servlet中,我在请求中添加以下内容:

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

在一种情况下,facetField.getName()评估为纪律。所以在我的页面中我有以下内容:

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>

循环运行一次,但所有输出都是空白的?!?如果它已经超过循环一次,我至少会期望项目中的某些东西。检查Facelets的调试弹出窗口,纪律是在那里和循环。将它打印到屏幕会产生一些看起来像我的地图(我缩短了输出):

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}

我'我也试过ac:forEach,但我得到的结果相同。那么有没有人有任何想法我会出错?

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?

感谢任何输入,
Lee

Thanks for any input, Lee

推荐答案

< ui:repeat> 只接受List或DataModel,而不接受Set或Maps。这是JSF 2.1的路线图。

<ui:repeat> only accepts List or DataModel, not Sets or Maps. This is on the roadmap for JSF 2.1.

这篇关于使用JSF,MyFaces&amp; amp; Facelets的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆