Domanda

I'm trying to capture the button click event on a button within a subwindow, to be handled by the parent. The parent component (this) implements ClickListener

Window newWindow = new Window("test");
MyComponent myComponent = new MyComponent();
newWindow.setContent(myComponent);
newWindow.setModal(true);
myComponent.saveBtn.addClickListener(this);
UI.getCurrent().addWindow(newWindow);

I get the following error:

The method addClickListener(ClickListener) in the type FocusWidget is not applicable for the arguments (this)

Is there some other method for capturing events in sub windows that I'm missing?

È stato utile?

Soluzione

You are likely importing com.google.gwt.user.client.ui.Button not com.vaadin.ui.Button. You can't add Vaadin ClickListener to GWT Button or vice versa.

Listening to button click events works in sub-windows just as everywhere else. So your code should otherwise be OK as long as 'this' really is implementing the correct interface.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top