3.5.5.2.3. ClearAction
ClearAction is a picker field action designed to clear the picker field. 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 com.haulmont.cuba.gui.actions.picker.ClearAction
class and should be defined in XML using type="picker_clear"
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 confirmation dialog before executing the action:
@Named("customerField.clear")
private ClearAction 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();
}