I have the following code:
private void check_bad_debt(Mailfile selected) {
badDebtDs.refresh(ParamsMap.of("lname", selected.getLname(), "postalCode", selected.getZip()));
if (badDebtDs.getItemIds().size() > 0) {
openWindow("rade$badDebtList",
WindowManager.OpenType.DIALOG,
ParamsMap.of("lname", selected.getLname(), "postalCode", selected.getZip())
).addCloseListener(actionId -> {
if (actionId.equals("onReject")) {
badDebt = true;
}
if (actionId.equals("onAccept")) {
badDebt = false;
}
});
}
}
with this screen declaration:
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="Possible Bad Debt "
class="com.paslists.rade.web.badDebtList.Baddebtlist"
focusComponent="btnAccept"
messagesPack="com.paslists.rade.web.badDebtList">
<dsContext>
...
</dsContext>
<actions>
...
</actions>
<dialogMode closeable="true"
forceDialog="true"
height="800"
modal="true"
resizable="true"
width="1024"/>
<layout>
</layout>
</window>
When I call this routine, I expected it to pop up the modal dialog under the correct conditions and wait for the user to click a button. Instead, the check_bad_debt function returns immediately, THEN the window opens up and the CloseListener fires when a button is pressed.
What I am trying to accomplish is that the data source is checked for data given a set of parameters. If there is data given those parameters, the modal window comes up and the user then gets the option to accept or reject the data. If they accept the data, then the process continues. If they reject the data, then the form is reset. How best to accomplish this?