AbstractWindow
is a subclass of AbstractFrame and defines the following methods:
-
validateAll()
– validates a screen. The default implementation callsvalidate()
for all screen components implementing theComponent.Validatable
interface, collects information about exceptions and displays corresponding message. Method returnsfalse
, if any exceptions were found; andtrue
otherwise.This method should be overridden only if it is required to override screen validation procedure completely. It is sufficient to implement a special template method –
postValidate()
, if validation should be just supplemented. -
postValidate()
– a template method that can be implemented in controller for additional screen validation. The method stores validation errors information inValidationErrors
object which is passed to it. Afterwards this information is displayed together with the errors of standard validation. For example:private Pattern pattern = Pattern.compile("\\d"); @Override protected void postValidate(ValidationErrors errors) { if (getItem().getAddress().getCity() != null) { if (pattern.matcher(getItem().getAddress().getCity()).find()) { errors.add("City name can't contain digits"); } } }
-
close()
– closes this screen.The method accepts string value, which is then passed to
preClose()
template method and toCloseListener
listeners. Thus, the information about the reason why the window was closed can be obtained from the code that initiated the closing event. It is recommended to use the following constants for closing edit screens:Window.COMMIT_ACTION_ID
after committing changes,Window.CLOSE_ACTION_ID
– without committing changes.If any of the datasources contains unsaved changes, a dialog with a corresponding message will be displayed before the screen is closed. Notification type may be adjusted using the cuba.gui.useSaveConfirmation application property.
A variant of
close()
method withforce = true
parameter closes the screen without callingpreClose()
and without a notification regardless of any unsaved changes.close()
method returnstrue
, if the screen is closed successfully, andfalse
– if closing procedure was interrupted. -
preClose()
is a template method which can be implemented in a controller to intercept the moment when the window closes. The method receives a string value provided by the closing initiator when invokingclose()
method.If the
preClose()
method returnsfalse
, the window closing process is interrupted.