-
1. Re: Get row Values of RichDataTable
mcmurdosound Sep 15, 2012 6:34 AM (in response to godoy)1 of 1 people found this helpfulYou have to use a DataVisitor to walk the tables model.
public void walkExtDT(String id) throws IOException {
FacesContext ctx = FacesContext.getCurrentInstance();
UIComponent component = ctx.getViewRoot().findComponent(id);
log.debug("component #0", component);
if (component != null && component instanceof HtmlExtendedDataTable) {
final HtmlExtendedDataTable t = (HtmlExtendedDataTable) component;
t.captureOrigValue(ctx);
DataVisitor visitor = new DataVisitor() {
@Override
public void process(FacesContext context, Object rowKey, Object argument)
throws IOException {
t.setRowKey(rowKey);
Iterator<UIColumn> colIter = t.getChildColumns();
while (colIter.hasNext()) {
UIColumn col = colIter.next();
List<UIComponent> children = col.getChildren();
for (UIComponent c : children) {
if (c instanceof UIOutput) {
System.out.println(((UIOutput) c).getValue());
}
}
}
}
};
t.walk(ctx, visitor, null);
t.restoreOrigValue(ctx);
t.setRowKey(null);
}
}
-
2. Re: Get row Values of RichDataTable
mcmurdosound Sep 15, 2012 7:51 AM (in response to mcmurdosound)ah sorry, my example is for the extendedDataTable. To use with the standard datatable you'll have to change to HtmlDataTable. This should do the trick.
No componentbinding required! Just pass the clientId of the table to the method.