具有List< List>的动态列在< p:dataTable>< p:columns>中 [英] Dynamic columns with List<List> in <p:dataTable><p:columns>
问题描述
我正在尝试使用dinamycally生成带有列的dataTable
,所以我有一个List<List>
当List
内的List
是我的列的内容时,但是当我尝试显示它时,我显示的内容不会太多.
I'm attempting to generate a dataTable
with columns dinamycally, so I've a List<List>
when a List
inside of a List
is the content of my column, but when I try to show it I can't display not much.
所以,这是我的Bean的代码:
So, this is the code of my Bean:
@ManagedBean
@javax.faces.bean.ViewScoped
public class Controlador {
private List<List> estadistico;
@PostConstruct
public void inicializar(){
this.estadistico = new ArrayList<List>();
this.estadistico.add( Arrays.asList( new Integer[]{0,1,24}));
this.estadistico.add( Arrays.asList( new Integer[]{5,1,34}));
this.estadistico.add( Arrays.asList( new Integer[]{12,1,4}));
}
//getter's and setter's
}
这是视图:
<h:form>
<!-- estadistico is List<List> -->
<p:dataTable value="#{controlador.estadistico}" var="lista">
<!-- lista is List of numbers
and I suppose that value is each number
-->
<p:columns value="#{lista}" var="value" >
#{value}
</p:columns>
</p:dataTable>
</h:form>
我希望有些像:
---------------
0 5 12
---------------
1 1 1
---------------
24 34 4
---------------
我在做什么错了?
正确的方法是什么?
推荐答案
<p:columns value>
无法引用<p:dataTable var>
.从技术和逻辑上讲,不可能逐行控制列.必须在每个表的基础上对其进行控制.
The <p:columns value>
cannot refer the <p:dataTable var>
. It is technically and logically not possible to control the columns on a per-row basis. They have to be controlled on a per-table basis.
如果您的模型保证每个嵌套列表的大小都相同,则应该这样做:
If your model guarantees that every nested list has the same size, then this should do:
<p:dataTable value="#{controlador.estadistico}" var="lista">
<p:columns value="#{controlador.estadistico[0]}" columnIndexVar="i">
#{lista[i]}
</p:columns>
</p:dataTable>
另请参见 <p:columns>
展示柜.
See also the <p:columns>
showcase.
这篇关于具有List< List>的动态列在< p:dataTable>< p:columns>中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!