3.5.5.2.11. RefreshAction

RefreshAction is a list action designed to reload the data container which is used by the table or tree component.

The action is implemented by com.haulmont.cuba.gui.actions.list.RefreshAction class and should be defined in XML using type="refresh" action’s attribute. You can configure common action parameters using XML attributes of the action element, see Declarative Actions for details.

If you want to perform some checks or interact with the user before the action is executed, subscribe to the action’s ActionPerformedEvent and invoke execute() method of the action when needed. In the example below, we show a custom confirmation dialog before executing the action:

@Named("customersTable.refresh")
private RefreshAction customersTableRefresh;

@Subscribe("customersTable.refresh")
public void onCustomersTableRefresh(Action.ActionPerformedEvent event) {
    dialogs.createOptionDialog()
            .withCaption("Please confirm")
            .withMessage("Are you sure you want to refresh the list?")
            .withActions(
                    new DialogAction(DialogAction.Type.YES)
                            .withHandler(e -> customersTableRefresh.execute()), // execute action
                    new DialogAction(DialogAction.Type.NO)
            )
            .show();
}

You can also subscribe to ActionPerformedEvent and instead of invoking the action’s execute() method, trigger the data loader directly. For example:

@Inject
private CollectionLoader<Customer> customersDl;

@Subscribe("customersTable.refresh")
public void onCustomersTableRefresh(Action.ActionPerformedEvent event) {
    customersDl.load();
}