The dialog created with
dialogs.createOptionDialog() it is not modal and does not have a .withModal method like createMessageDialog().
How do i make it modal ?
Hello!
Unfortunately, you cannot make it modal, for now. I created an issue: Haulmont/jmix-ui#499.
As a workaround you can create a screen and open it as modal dialog:
UserBrowse dialog = screenBuilders.screen(this)
.withScreenClass(UserBrowse.class)
.withOpenMode(OpenMode.DIALOG)
.build();
DialogWindow window = (DialogWindow) dialog.getWindow();
window.setModal(true);
dialog.show();
Hi Roman, can you please provide an example of how to make modal an exceptionDialog? I’m using Jmix 1.5.5, or it is the same workaround as the option dialog?
Hi David!
If you try to show an exception dialog from the Dialogs
bean, it would be easier not to create a screen, but rather to create the ExceptionDialog
instance itself:
private static final Logger log = LoggerFactory.getLogger(SomeScreen.class);
@Subscribe
public void onInit(final InitEvent event) {
IllegalStateException exception = new IllegalStateException("Exception");
ExceptionDialog exceptionDialog = new ExceptionDialog(exception,
"Exception dialog", "Exception is thrown", getApplicationContext());
exceptionDialog.setModal(true);
if (AppUI.getCurrent() != null) {
AppUI.getCurrent().addWindow(exceptionDialog);
log.error("Exception is thrown", exception);
}
}
However, you cannot manage the modality of exception dialogs that are displayed by the framework…
1 Like