Easy formatting of columns

Hi!

What’s the easiest way of formatting the data in a Table? I have a BeanItemContainer with a Bean in it that contains Strings, Doubles and Integer. The String and the Integers are formatted well, but the Doubles have to many numbers after the comma.

Normally, I would use a DecimalFormat or something like that but I don’t know how to tell Vaadin.

The first idea was to change the Bean (returning Strings instead of Doubles), but if I do this, I don’t have a change to have the columns sorted in a good way.

I saw that there’s a way of adding a ColumnGenerator to a Generated Column, but my columns are just the properties of the Bean and for those, there’s no need to add a generated column.

Hi!

Override method called formatPropertyValue in your Table and use DecimalFormat for Doubles in the function.

cheers,
matti

my workaround was add a generated column with the same name and do the formatting there, but your solution is much easier and shorter.

thx.

formatPropertyValue and PropertyFormatter is one area where more examples would be useful. When learning the framework, people often learn by example, and neither the official examples nor the book use these features. I used Generated Columns and fields as well, because when all you have is a hammer, everything looks like a nail…