【问题标题】:How to iterate Map<Map, Map> over jsf..?如何在 jsf 上迭代 Map<Map, Map> ..?
【发布时间】:2012-10-01 09:51:28
【问题描述】:

我有一张地图,我想在 jsf 上进行迭代。地图如下 -

LinkedHashMap<Map<String,String>,Map<String,String>>           propertyMap=new       LinkedHashMap<Map<String,String>,Map<String,String>>();

之前我已经在字符串类型的 jsf 上迭代了以下映射,以下列方式进行字符串

 List documentProperties = new ArrayList(propertyMap.entrySet());

在 jsf 中:-

   <af:iterator value="#{EditProperties.documentProperties}" var="list" id="i1">
              <trh:rowLayout id="rl1">
                    <trh:cellFormat id= "cf3"><af:outputText value="#{list.key}"
                                                             id="ot1"/>   </trh:cellFormat>
                    <trh:cellFormat id= "cf4">
                        <af:inputText id="it1"
                                      value="#{list.value}" showRequired="false">
                        </af:inputText>    
                    </trh:cellFormat>
              </trh:rowLayout>

但是我如何在 jsf 上迭代包含两个地图的地图..? 谢谢

【问题讨论】:

  • Map 的键应该是不可变的?为什么要使用两张地图?
  • 由 Map 键入的 Map 听起来是个非常糟糕的主意...
  • 但我的要求是我想在 jsf 页面上显示 4 个值,来自一个 spurce 本身
  • 您能否详细说明您的要求?

标签: java jsf


【解决方案1】:

Map 作为key 是个坏主意。您应该使用 Immutable 对象作为 hashmap 的键。 如果你想在 Map 中声明 Map 那么你可以做如下的事情。

LinkedHashMap<String,Map<String,Map<String,String>>> propertyMap=new LinkedHashMap<String,Map<String,Map<String,String>>>();

【讨论】:

  • 我的眼睛被所有的仿制药伤害了:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-12-18
  • 2011-09-15
  • 1970-01-01
  • 2016-10-08
  • 1970-01-01
  • 2019-06-28
  • 2017-10-08
相关资源
最近更新 更多