I have a class that contains has a private member a combobox and extended CostomComponet as:
class TelefonoWidgetView extends CustomComponent {
private ComboBox comboRecTel;
private VerticalLayout recTelLayout(){
comboRecTel = new ComboBox();
comboRecTel.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(ValueChangeEvent event) {
//do something
}
}
Now in another class I need to use that class (that I cannot modify) and have a Listener on the combobox; How I can do that?
Let say my new class is WidgetView, and is defined as
WidgetView {
private TelefonoWidgetView tel;
private void metho1(){
tel.addListener(new com.vaadin.ui.Component.Listener() {
private static final long serialVersionUID = 1L;
@Override
public void componentEvent(Event event) {
System.out.println( " scatto addListener su tel : ");
}
});
}
}
when I click on the combobox, I cannot see "scatto addListener su tel" on my console even if it compile correctly, It seems that the Listener has not been defined, while it is there!!
I know that I can create a combobox by myself but in the class TelefonoWidgetView there are other staff that I cannot copied;
I ve also tryed to put addDetachListener(new DetachListener(), addAttachListener(new AttachListener(),addContextClickListener(new ContextClickListener()
but no one is able to intercept the value change in the combobox
thanks a lot
You can use Java reflections API to access
comboRecTeleven though it isprivate.