-
1. Re: How to get the rendered rows of a dataTable?
mcmurdosound Nov 18, 2011 1:07 PM (in response to rubenlp)instead of value="#{datamodel}" being somekind of List<?>, you have to use an ExtendedTableDataModel (I'm not quite sure what the correct name was) or a ModifyableDataModel. After clientside filtering you can retrieve the actual visible rows (including pagination).
from: http://community.jboss.org/wiki/HowToGetFilteredDataFromTableToList :
public ModifiableModel getDataModel() {
if (this.DataModel == null) {
ExtendedTableDataModel<MyDataObj> model = new ExtendedTableDataModel<MyDataObj>(new DataProvider<MyDataObj>() {
private static final long serialVersionUID = 5054087821033164847L;
public MyDataObj getItemByKey(Object key) {
for (MyDataObj c : MyManagedBean.this.data) {
if (key.equals(getKey(c))) {
return c;
}
}
return null;
}
public List<MyDataObj> getItemsByRange(int firstRow, int endRow) {
return MyManagedBean.this.data.subList(firstRow, endRow);
}
public Object getKey(MyDataObj item) {
return item.getId();
}
public int getRowCount() {
return MyManagedBean.this.data.size();
}
});
this.dataModel = new ModifiableModel(model, "row");
}
return this.dataModel;
}public List<MyDataObj> getFilteredData() throws IOException {
final List<MyDataObj> filteredData = new ArrayList<MyDataObj>();
final ModifiableModel model = getDataModel();
getDataModel().walk(FacesContext.getCurrentInstance(), new DataVisitor() {
public void process(FacesContext context, Object rowKey, Object argument) {
model.setRowIndex((Integer)rowKey);
filteredData.add((MyDataObj) model.getRowData());
}
}, new SequenceRange(0, -1), null);
return filteredData;
}
-
2. Re: How to get the rendered rows of a dataTable?
rubenlp Nov 19, 2011 6:51 AM (in response to mcmurdosound)Thanks!!
That was waht I was looking for. Next time I will check out the knowledge base before asking
Saludos.
-
3. Re: How to get the rendered rows of a dataTable?
rubenlp Nov 22, 2011 9:09 AM (in response to mcmurdosound)Finally I used an ExtendedTableDataModifiableModel<T> instead of a ModifiableModel to make row selection work correctly on the ExtendedDataTable.
Thanks again.