rich:extendedDataTable
有一個屬性selection
綁定到一個變量中保存所選rows.This變量應在org.richfaces.model.selection.Selection
類型在MBean你rich:extendedDataTable
也應允許您選擇多線,可通過指定selectioMode
屬性來完成爲multi
所以,你rich:extendedDataTable
或許應該喜歡:
<rich:extendedDataTable value="#{mBean.custList}" selection="#{mBean.selection}" selectionMode="multi" >
在你該MBean,可以從mBean.selection
變量訪問選定行:
public class Mbean {
//List to be displayed to the rich:extendedDataTable
private List<Customer> custList ;
//Variable to hold the selected row
private SimpleSelection selection;
/*
Getter and setter of the custList and selection
*/
public void someMethod(){
//Code snippets to access the selected rows
Iterator<Object> iterator = this.selection.getKeys();
while (iterator.hasNext()){
Integer key = (Integer) iterator.next();
Customer cust = (Customer) this.custList.get(key);
System.out.println(cust.toString());
}
}
}
甜,謝謝。我永遠不會知道選擇標籤的深度! – Adam 2011-04-02 18:07:49