How to format generated columns by object type?

Hi,

as written in the vaadin help, I specified the formatPropertyValue to apply a NumberFormat for all BigDecimal.class.
It works fine for beans that have a BigDecimal member field.

But what about generatedcolumns, that themself return a BigDecimal (that may e.g. be calculated on the fly). I cannot see any formatting there. Why?



            //let all BigDecimals have 2 fractions
            Table table = new Table() {
			@Override
			protected String formatPropertyValue(Object rowId, Object colId, Property property) {
				if (property.getType() == BigDecimal.class) {
					NumberFormat formatter = NumberFormat.getNumberInstance();
					formatter.setMaximumFractionDigits(2);
					formatter.setMinimumFractionDigits(2);
					return formatter.format((BigDecimal) property.getValue());
				}

				return super.formatPropertyValue(rowId, colId, property);
			}
		};

table.addGeneratedColumn("amount", new AmountColumnGenerator());


//a generated column returning a big decimal. should be formatted as specified above, but does NOT!
public class AmountColumnGenerator implements Table.ColumnGenerator {
	@Override
	public Object generateCell(Table source, Object itemId, Object columnId) {
		return new BigDecimal(123);
	}
}


Hi,

as the name suggests, the formatPropertyValue is only called for properties in the container. Generated columns are not such. You could instead format the value readily in your column generator and return the formatted value directly.