EntityClearAction
EntityClearAction
is an entity picker action designed to clear the value of EntityPicker. If the field displays a one-to-one composition entity, the entity instance will also be removed on DataContext
commit (if the screen is an entity editor, it happens when the user clicks OK).
The action is implemented by the io.jmix.ui.action.entitypicker.EntityClearAction
class and should be defined in XML using type="entity_clear"
action’s attribute. You can configure common action parameters using XML attributes of the action element. See Declarative Actions for details.
Using ActionPerformedEvent
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 the execute()
method of the action when needed. In the example below, we show a confirmation dialog before executing the action:
@Named("customerField.clear")
private EntityClearAction customerFieldClear;
@Subscribe("customerField.clear")
public void onCustomerFieldClear(Action.ActionPerformedEvent event) {
dialogs.createOptionDialog()
.withCaption("Please confirm")
.withMessage("Do you really want to clear the field?")
.withActions(
new DialogAction(DialogAction.Type.YES)
.withHandler(e -> customerFieldClear.execute()), // execute action
new DialogAction(DialogAction.Type.NO)
)
.show();
}