hi, please help me for vaadin 8 validation using binder.
I am using pojo User.java having fields like name, [b]
countryCode, mobile, email etc…
countryCode is a combobox of other bean/Pojo which is SystemCountry (this bean have id and country name fields)
now while applying validation usin binder of User pojo how can I apply validation on for countryCode (combobox field)
[/b]
country code field initialised as
ComboBox countryCode = new ComboBox<>();
Provided values as,
countryCode.setWidth(“65px”);
countryCode.setItems(systemCountries); //list of system country provided
countryCode.setItemCaptionGenerator(SystemCountry::getCountryName);
//Trying validation like
countryCode.setRequiredIndicatorVisible(true);
binder.forField(countryCode)
.withValidator(str → str == null || “”.equals(str), “Please select country”)
bind(User::getCountryCode, User::setCountryCode); // This line doesn’t accept User country code variable
and if I commit bind(User::getCountryCode, User::setCountryCode); this line while loading form it thorwing error like below,
java.lang.IllegalStateException: Property type ‘java.lang.String’ doesn’t match the field type ‘com.enovate.client.core.pojo.SystemCountry’. Binding should be configured manually using converter.
at com.vaadin.data.Binder.bindProperty(Binder.java:2243)
at com.vaadin.data.Binder.lambda$null$12(Binder.java:2148)
at com.vaadin.data.Binder$$Lambda$6165/1444034637.apply(Unknown Source)
please help me in same case. how can I implement or where I am wrong?