Refresh browse include edit window

Hi

I need refresh browse include edit window. I modify datasource in postCommit method

protected boolean postCommit(boolean committed, boolean close) {
		boolean result = super.postCommit(committed, close);
		if ((committed) && (result)) {
			LoadContext<DocTypesToLedger> lc = new LoadContext<>(DocTypesToLedger.class);
			DocTypesToLedger curritem = (DocTypesToLedger) getContext().getParams().get("ITEM");
			if (def.getValue()) {
				Integer ledgerId = curritem.getLedger().getId();
				lc.setQueryString("select r from publisher$DocTypesToLedger r where r.ledger.id = :ledger")
						.setParameter("ledger", ledgerId);
				lc.setView(View.BASE);
				List<DocTypesToLedger> list = docTypesToLedgerDs.getDataSupplier().loadList(lc);
				for (DocTypesToLedger item : list) {
					if (!(item.getId().equals(curritem.getId()))) {
						item.setIsdefault(false);
						docTypesToLedgerDs.getDataSupplier().commit(item);
					}
				}
			}
		}
		return result;
	}

I find topic abou it and I add in browse in init method refresh – > setAfterCommitHandler(entity -> docTypesToLedgersDs.refresh())

but browse doesn’t refresh.

Hi,

I’ve tried to implement your idea in the CUBA Quick Start sample application, and it works:

OrderBrowse.java :

public class OrderBrowse extends AbstractLookup {

    @Named("ordersTable.create")
    private CreateAction ordersTableCreate;
    @Inject
    private GroupDatasource<Order, UUID> ordersDs;

    @Override
    public void init(Map<String, Object> params) {
        ordersTableCreate.setAfterCommitHandler(entity -> {
            showNotification("Committed in editor", NotificationType.HUMANIZED);
            ordersDs.refresh();
        });
    }
}

OrderEdit.java :

public class OrderEdit extends AbstractEditor<Order> {
    @Inject
    private Datasource<Order> orderDs;

    @Override
    protected boolean postCommit(boolean committed, boolean close) {
        boolean result = super.postCommit(committed, close);
        if (committed && result) {
            LoadContext<Order> loadContext = new LoadContext<>(Order.class);
            UUID orderId = getItem().getId();
            loadContext.setQueryString("select e from sales$Order e where e.id = :orderId")
                    .setParameter("orderId", orderId);
            loadContext.setView("order-with-customer");
            Order order = orderDs.getDataSupplier().load(loadContext);
            if (order != null) {
                order.setAmount(order.getAmount().multiply(new BigDecimal(100000)));
                orderDs.getDataSupplier().commit(order);
            }
        }
        return result;
    }
}

Here it is: sales.zip (85.8 KB)

It would be helpful if you could attach a sample of your project.

I explain my problem precisely. I have edit window like this

obraz

I would like refresh documentList browse. When I create setAfterCommitHandler in this browse controler I have no effect because this code is never running, but I may create setAfterCommitHandler in Ledger editor. When I accept documentList edit window I give message committed in editor and bowser no refresh.

I see. You can use the Events mechanism.
See also:
https://www.cuba-platform.com/discuss/t/refreshing-datasource-when-data-changed/3566
https://www.cuba-platform.com/discuss/t/refresh-a-screen-datasource-if-the-datasource-items-have-been-changed-externally/498
https://www.cuba-platform.com/discuss/t/how-to-use-aftercommithandler-refresh-when-coming-from-a-composite-entity-create-screen/2686/2

Hi Olga.

Might I send my project to us ? I try all possibilities. I use refresh browse in other function and it’s woking ok.
I thing, It’s specific issue because browse is inner edit window.

Yes, a small sample project would be really helpful, or at least the clear explanation of your data model and the code of screen descriptors and controllers.

Hi

I attach my project. I update data in class DocTypesToLedgerEdit method postCommit and I try refresh browse in addCloseWithCommitListener in this same class. Publisher.zip (1.1 MB)