Item shows up as 'null' in textfield

Hi All

I’m going through the addressbook app and I’ve the following issue. The PostalCode in is by default ‘null’ (its an Integer).
Now, when I want to create a new Person, the PersonForm puts ‘null’ in the text field.
All the other fields are set to “” and don’t have this problem:

public class Person implements Serializable {
          private String firstName = "";
          private String lastName = "";
          private String email = "";
          private String phoneNumber = "";
          private String streetAddress = "";
          private Integer postalCode = null;
          private String city = "";

What can I do so the texfield is empty instead of showing ‘null’ for the postal code?


ps To create a new Person, the PersonForm does the following:

public void addContact() {
            // Create a temporary item for the form
            newPerson = new Person();
            setItemDataSource(new BeanItem(newPerson));
            newContactMode = true;

You can set the null representation for TextFields. To accomplish what you want Insert the following at the end (must be after the setItemDataSource() call) of your addContact():

((TextField) contactEditor.getField("postalCode")).setNullRepresentation("");

yes, thats it! Thnx