Hi
Sorry for noob question
I have created a component implements HasValue, all is fine ,
I have create an event listener both on Lit and Server
i just can’t find the right to implement : Registration addValueChangeListener
my code
@Tag("country-picker")
@JsModule("./app/countries/country-picker.js")
public class CountryPicker extends Component implements HasValue<HasValue.ValueChangeEvent<ACountry>,ACountry>,HasLabel {
private ACountry aCountry = null;
/** this is EventListener interface **/
private CountryPickerValueChangeListener valueChangeListener;
public CountryPicker() {
new PickerValueChange(this,detail -> {
if (detail != null) {
aCountry = Countries.getInstance().getCountryByIso2(detail.getString("value"));
if (valueChangeListener!=null) {
valueChangeListener.valueChange(aCountry);
}
}
});
}
@Override
public void setValue(ACountry aCountry) {
getElement().setProperty("value",aCountry.getIso2());
}
@Override
public ACountry getValue() {
return aCountry;
}
public void valueChange(CountryPickerValueChangeListener valueChangeListener) {
this.valueChangeListener = valueChangeListener;
}
@Override
public Registration addValueChangeListener(ValueChangeListener<? super ValueChangeEvent<ACountry>> valueChangeListener) {
return null;
}
@Override
public void setReadOnly(boolean b) {
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public void setRequiredIndicatorVisible(boolean b) {
}
@Override
public boolean isRequiredIndicatorVisible() {
return false;
}
public interface CountryPickerValueChangeListener {
void valueChange(ACountry aCountry);
}
}
by the way this is result