You can do this in a managed bean:
public class ArrayDataBean {
private Object[] rows = { "One", "Two", "Three" };
private final DataModel dataModel = new ArrayDataModel(rows);
public DataModel getDataModel() {
return dataModel;
}
public String addRow() {
Object[] newArray = new Object[rows.length + 1];
System.arraycopy(rows, 0, newArray, 0, rows.length);
newArray[rows.length] = "NewRow" + System.currentTimeMillis();
rows = newArray;
dataModel.setWrappedData(rows);
return null;
}
}
source
share