【发布时间】:2016-03-28 13:09:30
【问题描述】:
我正在开展一个项目,该项目需要我显示并能够选择和存储产品标签。标签以树状结构提供。我不能假设标签树的最大深度。
我想显示按级别拆分的标签,使用 c:forEach - p:selectManyCheckbox - f:selectItems,并使用 p:ajax 组件处理选择。
我使用以下类型在 Tree 对象中存储可能的值和选择:
HashMap<Long, ArrayList<Tag>> tree;
HashMap<Long, Object[]> selected;
Hashmap 键等于“标签级别”。
为了显示值,我使用以下代码进行测试:
<p:panelGrid id="tagDisplay" columns="2">
<c:forEach begin="1" end="5" var="idx">
<p:outputLabel value="#{idx}"></p:outputLabel>
<p:selectManyCheckbox value="#{product.tags.selected[1]}">
<f:selectItems value="#{product.tags.tree[1]}" var="tag" itemLabel="#{tag.name}" itemValue="#{tag.id}" />
<p:ajax listener="#{product.selectorListener}" update="tagDisplay" />
</p:selectManyCheckbox>
</c:forEach>
</p:panelGrid>
代码似乎运行良好,但显示了五次。
现在我一直在尝试将 Hashmap 动态绑定到选择器。当我用“idx”替换“1”时,我没有得到任何结果。
我尝试将 ui-repeat 与虚拟表一起使用,但后来我丢失了 panelgrid 结构。
任何帮助将不胜感激!
我的环境 - Websphere 8.5、JSF 2.2、Primefaces 5.2
【问题讨论】:
标签: jsf jsf-2 primefaces jstl