1
我做了一个表格和相应的SQLContainer。该表中有一个包含电话号码的列。在db表中对应列的类型是int。我希望Vaadin表的格式化值能够使查看电话号码变得没有像千位分隔符(8,888 - > 8888)那样的昏迷或点状。格式化表格单元格中的值
我已经作出了类似的事情,以表其数据来源是这样一个JPAContainer:
Table imenikTable = new Table("Imenik", imenikData){
/**
*
*/
private static final long serialVersionUID = 8213291207581835298L;
@Override
protected String formatPropertyValue(Object rowId,
Object colId, @SuppressWarnings("rawtypes") Property property) {
Object v = property.getValue();
if (v instanceof Integer) {
DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(getLocale());
df.applyLocalizedPattern("##00");
return df.format(v);
}
return super.formatPropertyValue(rowId, colId, property);
}
};
而且一切正常。但是当我用SQLContiner而不是JPAContainer进行类似的构建时,简单地忽略了它。我试图改变这样的方式:
StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter(){
private static final long serialVersionUID = -7517984934588222147L;
protected NumberFormat getFormat(Locale locale){
NumberFormat format = super.getFormat(locale);
format.setGroupingUsed(false);
return format;
}
};
contaktListTable.setConverter("telbr", plainIntegerConverter);
但仍然我的环境忽略我,甚至没有错误信息!有什么问题?
是的,我检查过。我也得出了同样的结论。我正在尝试在演示文稿级别上进行转换。在MySql基础中是int类型。什么类型可以在SQLcontainer转换之前在表(它变成字符串)? – vmaric
是的,我检查与断点。这个值不是整数。 – vmaric
您使用Oracle DB吗? vaadin这本书讲述了这一点:当使用Oracle数据库时,Oracle JDBC驱动程序将大部分或全部数字类型转换为java.lang.BigDecimal的 。 –