Problem "Cannot format given Object as a Number" adding Items to an IndexCo

Hi, I got a problem adding Items to an IndexContainer bounded to a Table.

Debugging I saw that the line that raise the exception is the StringToLongConverter class when it tries to convert using the locale.

Of course I tried to change my locale but the problem still occurs.

Is there anyone that have experienced the same problem or have a solution?

Those are the portion of code that produce the exception…

kind regards
Giovanni

Table.class

value = getPropertyValue(id, colids[j]
, p);
} catch (Exception e) {
exceptionsDuringCachePopulation.add(e);
value = null;
}

AbstractStringToNumberConverter.class

StringToLongConverter.class

@Override
protected NumberFormat getFormat(Locale locale) {
if (locale == null) {
locale = Locale.getDefault();
}
return NumberFormat.getIntegerInstance(locale);
}

this is the same error generated where the framework tried to refresh the table…

Caused by: java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:507)
at java.text.Format.format(Format.java:157)
at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:110)
at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:35)
at com.vaadin.ui.Table.formatPropertyValue(Table.java:4172)
at com.vaadin.ui.Table.getPropertyValue(Table.java:4114)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2386)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2225)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1745)

The problem is that the framework tries to convert una empty string (“”) to a number…
anyone knows how to avoid that ? Can I disable Cache population?

I temporarly solved getting the Item after the exception with the ItemId I’ve used
to add the item to the container…

try {
item = container.addItem(element.getId());
} catch (Exception ex) {
item = container.getItem(element.getId());
}

but it’s only a work around :frowning: