Disable Save Confirmation Dialog popup on Save

Hi, I have this code where essentially it will reload the page with the same entity, but after it’s saved in the db

public class SelfBillingTransactionDetailView extends StandardDetailView<TrxHead> {
//
//

public void onSaveBtnClick(final ClickEvent<JmixButton> event) {
TrxHead trx = datamanager.save(getEditedEntity());
viewNavigators.detailView(TrxHead.class)
                            .editEntity(trx)
                            .withViewClass(SelfBillingTransactionDetailView.class)
                            .navigate();
}
}

I understand that when navigating to other page, it will consider as closing the page, so a save confirmation dialog will show. i want it to not show in this particular instance.
I also tried using closeWIthSave() method with then(), but it goes back to the list view page before navigating into the edit page

closeWithSave()
                .then(() ->
                {
                    TrxHead trx = datamanager.save(getEditedEntity());
                    viewNavigators.detailView(TrxHead.class)
                            .editEntity(trx)
                            .withViewClass(SelfBillingTransactionDetailView.class)
                            .navigate();
                });

Is there any way to override the default method and disable the save confirmation dialog? Thank you in advance.
Regards.

Hi, @amirulmukminin

There is a standard action that saves an edited entity and does not close the view. See docs.
Example of declaration in the view descriptor:

<view xmlns="http://jmix.io/schema/flowui/view"
      title="msg://departmentDetailView.title"
      focusComponent="form">
    <!-- ... -->
    <actions>
        <action id="saveAction" type="detail_save"/>
        <action id="closeAction" type="detail_close"/>
    </actions>
    <layout>
        <!-- ... -->
        <hbox id="detailActions">
            <button id="saveBtn" action="saveAction"/>
            <button id="closeBtn" action="closeAction"/>
        </hbox>

Regards,
Maria.

Thank you. I managed to achieve my desired behaviour by using this action + afterSaveEvent handler.

Hi,

As today when i run the program, details_save closes the view. It works as intended previously. May I know what changes?

Here is my code:
XML:

<actions>
        <action id="saveAction" type="detail_save"/>
        <action id="saveCloseAction" type="detail_saveClose"/>
        <action id="closeAction" type="detail_close"/>
    </actions>
//...
<button id="createBtn" action="trxLinesDataGrid.create"/>
<button id="testBtn" text="Create with Save Close Action"/>

Controller:

@Subscribe(id = "testBtn", subject = "clickListener")
    public void onTestBtnClick(final ClickEvent<JmixButton> event) {
        saveCloseAction.execute();
        viewNavigators.detailView(TrxLine.class)
                .withViewClass(TrxLineDetailView.class)
                .withBackwardNavigation(true)
                .withQueryParameters(QueryParameters.of("trx_id", String.valueOf(getEditedEntity().getId())))
                .newEntity()
                .navigate();
    }


    @Subscribe("trxLinesDataGrid.create")
    public void onCreateLines(final ActionPerformedEvent event){
        saveAction.execute();
        viewNavigators.detailView(TrxLine.class)
                .withViewClass(TrxLineDetailView.class)
                .withBackwardNavigation(true)
                .withQueryParameters(QueryParameters.of("trx_id", String.valueOf(getEditedEntity().getId())))
                .newEntity()
                .navigate();
    }

The saveAction closes the view, return it to the list page, but saveCloseAction returns it to the dashboard/root url (localhost:8080).
I screen recorded my screen but i cant upload it here, so here is the drive link for the video.

Why do you think that details_save closes the view?
You navigate to another view right after executing it, so the navigation closes your original view.

In the video, the clicking the button goes to the listing page then go to the TrxLineDetailView page. The viewNavigators pnly navigate to TrxLineDetailView page directly. When I didn’t put the saveAction.execute() in the code, it asks a save confirmation (which i’m trying to avoid thats why im triggering saveAction.execute() there),clicking Save will save and goes to listing page (not even going to TrxLineDetailView page).

Also, I run this code:

    public void onCreateLineBtnClick(final ClickEvent<JmixButton> event) {
        saveAction.execute();
    }

This is what happens.

Make sure your injected saveAction is really of detail_save type, because in standard generated views this action is actually detail_saveClose. You can check it in the debugger by stepping into your saveAction.execute() call - the action class should be DetailSaveAction.

Also, note that you can override the hasUnsavedChanges() method of your detail view to get rid of unsaved changes notifications.

If it doesn’t help, please create a small test project which demonstrates your problem and attach it here.

Thank you for your suggestion.
I managed to workaround this issue using dataContext.save()
But as a note, the saveAction does go to DetailSaveAction class when i run the debugger.

Thank you for your help.