我正在使用jsf Mojarra 2.2.7,Java 8,Primefaces 5.1和netbeans 8.0.2
我有Event一个属性的班级List<GameRecord> gameRecordList.GameRecord包括List<Boolean> gamesEntered和其他属性.我的想法是,我有一个活动中的人员列表,如果他们进入投注或比赛,我正在配置.
在我的.xhtml文件中
<p:dataTable value="#{events.gameRecordList}" var="item" rowIndexVar="rowIndex">
<p:column>#{item.field1}</p:column>
<p:column>#{item.field2}</p:column>
<c:forEach items="#{events.gameRecordList.get(rowIndex).gamesEntered}" var="game">
<p:column>
<p:selectBooleanCheckbox value="#{game}"/>
</p:column>
</c:forEach>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
本<c:forEach>应一起工作value="#{item.gamesEntered}",而不是整个字符串,但事实并非如此.我试过<ui:repeat>但无论哪种方式,页面都会出现空白,此数据应该出现.
这是否有意义或是否有理由需要完全寻址才能使其正常工作?
我正在使用Java 8(build 1.8.0_25),Netbeans 8.0.2,并将一些Java 8功能集成到现有应用程序中.排序和.forEach不起作用,所以我创建了一些测试代码,以确保我理解lambdas等,并诊断问题.下面是新代码和代码的混合,以便与我的系统中的数据进行交互:
public void test(Registration reg) {
/* new code */
List<String> family = new ArrayList<>();
family.add("Mom");
family.add("Dad");
family.add("Brother");
family.add("Sister");
family.forEach(p -> System.out.println(p));
Collections.sort(family, (p1,p2) -> {
System.out.println(p1 + " <==> "+ p2);
return p1.compareToIgnoreCase(p2);
});
family.forEach(p -> System.out.println(p));
/* code to test with my system data */
List<RegistrationItem> item = new ArrayList<>();
List<RegistrationItem> regI = reg.getRegistrationItem();
regI.forEach(p -> {
System.out.println(p.toString());
item.add(p);
});
Collections.sort(regI, (r1,r2) -> {
System.out.println(r1.toString() + r2.toString());
return r1.getId().compareTo(r2.getId());
});
for (RegistrationItem r : …Run Code Online (Sandbox Code Playgroud) collections ×1
datatable ×1
foreach ×1
java ×1
java-8 ×1
java-stream ×1
jpa ×1
jsf ×1
jstl ×1
primefaces ×1