Hi DataBinding is not wroking even add Convertor.
How can we added Native Select , Convertor is not called at all .
I have BeanItemContainer to load Native select.
public class Department implements Serializable{
private static final long serialVersionUID = 1L;
private Long deptId;
private String name;
// setters & getters.
}
public class Employee implements Serializable{
/**
* serialVersionUID
*/
private static final long serialVersionUID = 1L;
private String firstName;
private String lastName;
private Long department;
// working fine if departmet is Department type, but my requirement is only Long value will come in field bean.
}
Field Group with bind;
Employee emp=new Employee();
emp.setDepartment(new Long(1));
emp.setFirstName(“Palanivel”);
emp.setLastName(“Kainattu”);
fieldGroup = new BeanFieldGroup(Employee.class);
fieldGroup.setItemDataSource(emp);
fieldGroup.bindMemberFields(this);
and Convertor is .
public class SelectConvertor implements Converter< Department,Long>{
private static final long serialVersionUID = -220989690852205509L;
@Override
public Long convertToModel(Department value,
Class<? extends Long> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
System.out.println(“–> getting”);
return (value!=null?value.getDeptId():null);
}
@Override
public Department convertToPresentation(Long value,
Class<? extends Department> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
Department dept = new Department();
dept.setDeptId(value);
System.out.println(“–> getting”);
return dept;
}
@Override
public Class getModelType() {
System.out.println(“–> getting”);
return Long.class;
}
@Override
public Class getPresentationType() {
System.out.println(“–> getting”);
return Department.class;
}
}