When I click on an line to edit it, and thus enter edit mode, for some reason null values display as “null”. Why? What is really weird it is only columns/fields where I did column.setEditable(true);
.
Code that sets null representation to blank.
column = addTextColumn(grid, propertyId, caption);
if(column.getEditorField() instanceof TextField)
{
TextField field = (TextField) column.getEditorField();
field.setNullRepresentation("");
}
if( Arrays.asList(EDITABLE_COLUMNS).contains(propertyId) )
column.setEditable(true); // These columns have the null problem
else
column.setEditable(false); // These problems do not have the null problem
And then we have the addTextColumn
interface method, which, by default, sets it to blank as well:
default Column addTextColumn( Grid grid, Object propertyId, String caption )
throws IllegalStateException {
Column column = addColumn(grid, propertyId, caption, String.class);
TextRenderer renderer = new TextRenderer();
column.setRenderer(renderer);
return column;
}
The TextRenderer()
constructor does this (copied from eclipse, to save time, but this is normal Vaadin 7 library, nothing custom):
/**
* Creates a new text renderer
*/
public TextRenderer() {
this("");
}
/**
* Creates a new text renderer
*
* @param nullRepresentation
* the textual representation of {@code null} value
*/
public TextRenderer(String nullRepresentation) {
super(String.class, nullRepresentation);
}
As you can see from all of the above code, it should display blank, but it displays “null”: