Sometimes you only have a list or array of objects you’d like to bind to a ListSelect or a Table and forget about the fancy Container features like lazy loading or automatic updates.
Now creating a Container from a list or array of beans, string, integers is easy. And you can configure the CollectionContainer to have different type of ids. CollectionContainer is a read-only Container implementation suitable best for small amounts of data, backed simply by a collection storage.
// Read using OpenCSV
CSVReader r = new CSVReader(new FileReader(file));
List<Object[]> rows = r.readAll();
// Extract column captions
String[] columnHeaders = (String[]
) rows.get(0);
rows.remove(0);
// Bind to table
CollectionContainer ds = CollectionContainer.fromPrimitives(rows, -1);
table.setContainerDataSource(ds);
table.setColumnHeaders(columnHeaders);
Disclaimer: As you can see here, the data is read fully into a List (which does not scale to large amounts) and no error checking is present (left it out for readability).
Anyway, this works very well for my case of “typical” amount of data (i.e. ~1000 rows, ~10 columns).