I want to transpose a Bean Container, and I don’t know how many columns I will get after doing this…for example, If I have a table with two columns, item and date, with n items and an indeterminate number of unique dates x, and I want to end up with a table with n rows and x+1 columns, with the dates as the container properties. This is easy to do if x is a fixed number but, how can I do this if I don’t know x? How can I create a Bean of x+1 size with the dates as properties (with x previously unknown)??
Instead of trying to fit BeanContainer for this, you could create your own container inheriting e.g. AbstractInMemoryContainer and use a PropertySetItem where you can add property instances, or take an approach similar to that of IndexedContainer where properties are created and read the data on the fly…
Note that in the general case, transposing data for Vaadin containers automatically is not always possible as different columns can have different data types. However, if your data is homogeneous or you present all the data e.g. as strings, a utility for transposing data may be doable with little effort.
Because it parses the columns (properties) from the properties (accessors/fields) of a JavaBean class, which it expects to get, and accesses the data directly from those beans. Unless you transpose your data into a separate list of beans which each correspond to a single row in the transposed table, BeanContainer tries to do things you don’t want it to do.
As for the original (underlying) container, in case you write a container than wraps one and transposes it on the fly, I had the impression that your original data could have a variable number of fields, so it is probably not in a format expected by BeanContainer. It might be possible to add custom properties to handle this, but again you would probably be “fighting against BeanContainer” more than it would take effort to implement a new and clean container inheriting AbstractInMemoryContainer.
unfortunately, for now, I will have to use the Beancontainer…
I have a Bean with three properties, Name (String), Last Name (String) and Total (Double)…As I iterate over another container (SQLContainer), I want to add properies to the bean as I find them, ending up with a bean like Name (String), Last Name (String), Prop X (Double), Prop Y (Double), Prop Z (Double) and Total (Double)…(instead of X, Y, and Z, it can be only X and Y, X and Z, etc, depending on what I find)…
after that, I create a Bean Container:
static BeanContainer<String, Bean> AAA = new BeanContainer<String, Bean>(Bean.class);
Besides adding properties to the Bean Class, I need to create the new beans based on these new properties…