Primefaces DataTable和DataGrid

时间:2014-01-20 06:57:46

标签: java-ee primefaces

我有Prime faces Check box Data TableData Grid.

                <p:dataTable id="****" }"
                             row="12"
                              selection="#{****.selected}">



                    <p:column headerText="name" style="width:25p">
                        #{****.xx}
                    </p:column>
                    <p:column headerText="name" style="width:25p">
                        #{****.xxx}
                    </p:column>


                </p:dataTable>

我从某些表中选择了一些行,但我的选择数组为空! 为什么?如何绑定我的选择数组?

1 个答案:

答案 0 :(得分:0)

尝试使用以下结构跟随数据表的结构,并选中复选框。

<p:dataTable id="****" var ="yourVar"   value = "#{Bean.PojoFileName}"
row="12"
selection="#{Bean.selectedValue}">
//selectedValue should be of type  private PojoFileName[] selectedValue;  
<p:column headerText="name" style="width:25p">
#{yourVar.xx}
</p:column>
<p:column headerText="name" style="width:25p">
#{yourVar.xxx}
</p:column>
</p:dataTable>
  1. 如果问题仍然存在,您可以捕获选中/未选中复选框的事件并在您的bean中处理它。