I implemented a Bean as:
public class SubscriptionBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String emailId;
private String confirmEmailId;
public String getConfirmEmailId() {
return confirmEmailId;
}
public void setConfirmEmailId(String confirmEmailId) {
this.confirmEmailId = confirmEmailId;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
}
I generated a form based on it. When i see the form it comes up with ‘null’ in the emailId and confirmEmailId fields. So, how to get that blank?
public Field createField(Item item, Object propertyId,
Component uiContext) {
TexTfield text = new TextFiedl();
text.setNullRepresentation("");
return text;
}
Btw. why the default null representation is ‘null’? I don’t see any reasonable scenario where text ‘null’ would be better option instead of ‘’ (empty string).
Even i agree that there is no reason to default it ‘null’ instead of blank.[quote=Antti Koski]
Btw. why the default null representation is ‘null’? I don’t see any reasonable scenario where text ‘null’ would be better option instead of ‘’ (empty string).
[/quote]
Form f = new Form();
f.setFormFieldFactory(new FormFieldFactory() {
public Field createField(Item item, Object propertyId,
Component uiContext) {
Field field = DefaultFieldFactory.get().createField(item,
propertyId, uiContext);
if (field instanceof TextField) {
((TextField) field).setNullRepresentation("");
}
return field;
}
});
f.setItemDataSource(new BeanItem(new Person()));
In practice this is not that much of extra as in most forms you want to set form field factory any case to customize the form behavior.