我有一个ace:dataTable,它包含可变数量的列。为此,我使用c:forEach标记。不显示在c:forEach中生成的所有内容。在示例中,仅显示columnLibelle和columnSum。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/pages/layer/layout.xhtml">
<ui:define name="content">
<ice:form id="myForm">
<h:panelGroup styleClass="table" layout="block">
<ace:dataTable id="myTable"
value="#{myBean.tableElements}"
var="currentElement" rowClasses="oddRow, evenRow" styleClass="tbl"
paginator="false">
<ace:column id="columnLibelle"
headerText="#{msg['common.libelle']}"
sortBy="#{currentElement.libelle}">
<h:outputText value="#{currentElement.libelle}" />
</ace:column>
<ace:column id="columnSum" headerText="#{msg['common.sum']}"
sortBy="#{currentElement.sum}">
<h:outputText value="#{currentElement.sum}">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
</ace:column>
<c:forEach items="#{currentElement.services}" var="currentService">
<ace:column headerText="#{msg[currentElement[currentService.service.label]]}"
sortBy="#{msg[currentElement[currentService.service.label]]}">
<h:outputText value="#{currentElement[currentService.service.value]}">
<f:convertNumber minFractionDigits="0" />
</h:outputText>
</ace:column>
</c:forEach>
</ace:dataTable>
</h:panelGroup>
</ice:form>
</ui:define>
</ui:composition>
</h:body>
</html>