Vaadin’s Table - is a excellent component.
And it has excellent method
formatPropertyValue
I think it is good idea to add
private Map<Object, PropertyFormatter> formatters = Collections.emptyMap();
+getter/setter
and this logic to formatPropertyValue (not tested):
protected String formatPropertyValue(Object rowId, Object colId, Property property) {
if (property == null) {
return "";
}
PropertyFormatter propertyFormatter = formatters.get(colId);
if (propertyFormatter != null) {
propertyFormatter.setPropertyDataSource(property);
String fmt = propertyFormatter.toString();
propertyFormatter.setPropertyDataSource(null);
return fmt;
}
return property.toString();
}
Then one will need to override formatPropertyValue in rare cases and can reuse battery of PropertyFormatters:
DoublePropertyFormatter, DateTimePropertyFormatter, etc.
Ticket
http://dev.vaadin.com/ticket/6513
- few out-of-box PropertyFormatter implementations: DoublePropertyFormatter, DateTimePropertyFormatter, CurrencyPropertyFormatter, BooleanPropertyFormatter