Hello Vaadin gurus,
I am trying to apply a converter to combobox and having extremely difficulty getting it work.
Issue #1 - When I apply a converter to a combobox Eclispse Luna flashes a warning. I read the forum for a solution and tried casting the converter and still the issues does not go away. When I execute the below code, I get a NullPointerException.
/**
- @return the filingMonth
*/
private ComboBox getFilingMonth() {
if (filingMonth == null) {
filingMonth = new ComboBox(“Filing Month”);
filingMonth.setWidth(FilingForm.FIELD_WIDTH);
filingMonth.setNullSelectionAllowed(false);
filingMonth.addItems(YearMonthUtil.getMonthNames());
filingMonth.setConverter((Converter) new MonthStringToInt());
}
return filingMonth;
}
Issue #2 - My data source (model) the filing month is an integer value. However, the combobox items (view) will display the month name. Since I cannot get the bean to register, I tried extending the combobox and and override the getValue() and setValue() mehtods. That didn’t work out as well.
private void bindBeanToForm() {
if (binder == null) {
binder = new FieldGroup();
binder.setBuffered(true);
}
binder.setItemDataSource(new BeanItem(this.filing));
binder.bind(filingMonth, “filingMonth”);
}
Is my approach correct or am I not using Converter properly.
Thanks.