Change dialog close(x) button behaviour

Hi, I opened a dialog from an existing detail view by using this code:

DialogWindow<TrxLineDetailView> window = dialogWindows.view(this, TrxLineDetailView.class).withAfterCloseListener(afterCloseEvent -> {
            if (afterCloseEvent.closedWith(StandardOutcome.SAVE)) {
                notifications.show("Trx Line saved successfully.");
                trxLinesDl.load();
                reloadHead();
            }
            trxHeadTaxesDl.load();
        }).build();
        TrxLine trxLine = dataManager.create(TrxLine.class);
        trxLine.setTrx(getEditedEntity());
        window.setWidth("80%");
        window.setHeight("80%");
        window.setCloseOnEsc(true);
        window.getView().setEntityToEdit(trxLine);
        window.addAfterCloseListener(e -> {
            dataManager.save(trxLine);
        });
        window.open();

The dialog have the small x button on top right of the dialog, which when closed, will ask for confirmation to save (even I didnt change anything). I noticed this code inside DialogWindow.class file

    protected void onCloseButtonClicked(ClickEvent<Button> event) {
        this.view.closeWithDefaultAction();
    }

is there any way that i can make it close with discard by default?

Regards

Hi, Muhammad!

You may create abstract class that is ancestor of StandardListView class, and add necessary listeners in its lifecycle methods(for examle “onInit” method). And you may extends you screens not from StandardListView class but from your CustomListView class.

Best regards, Pavel.