How/Where does *wizardCancelledEvent* get called?

Hi guys,

I am currently using wizards for vaadin and I simply want my wizard to end properly when I click on the “Cancel” button.

How do I achieve this? I know that Wizards for Vaadin provides us with predefined methods such as
wizardCancelled
but this doesnt really seem to work:

public void wizardCancelled(WizardCancelledEvent event) { endWizard("Wizard cancelled!"); Notification notification = new Notification("Wizard cancelled!"); notification.setDelayMsec(1000); notification.show(Page.getCurrent()); } When I click on cancel, nothing happens. Not even the notification shows. Do I need to do anything else?

Hi,

I haven’t tried it, but looking at the Wizards for Vaadin source, it looks like a WizardCancelledEvent should be fired when the Cancel button is pressed. Your snippet only shows a method that takes an event parameter; do you also have a listener added to your wizard? From the
Wizard’s source docs
:

* To react on the progress, cancellation or completion of this {@code Wizard}
* you should add one or more listeners that implement the
* {@link WizardProgressListener} interface. These listeners are added using the
* {@link #addListener(WizardProgressListener)} method and removed with the
* {@link #removeListener(WizardProgressListener)}.

I must have totally missed adding the listener in my wizard constructor! I will try this out, thanks :slight_smile:

I added the listener and as expected, this solved the issue right away. Now my Cancel gets called properly as intended, thx!

Could you please let me know how to add the listener?