ooodev.adapter.form.submission.submission_veto_listener module
- class ooodev.adapter.form.submission.submission_veto_listener.SubmissionVetoListener(trigger_args=None, subscriber=None)[source]
Bases:
AdapterBase,XSubmissionVetoListenerIs implement by components which want to observe (and probably veto) the submission of data.
See also
- Parameters:
args (Any) –
kwargs (Any) –
- Return type:
Any
- __init__(trigger_args=None, subscriber=None)[source]
Constructor
- Parameters:
trigger_args (GenericArgs, Optional) – Args that are passed to events when they are triggered.
subscriber (XSubmission, optional) – An UNO object that implements the
com.sun.star.form.XSubmissioninterface. If passed in then this listener instance is automatically added to it.
- Return type:
None
- disposing(Source)[source]
Gets called when the broadcaster is about to be disposed.
All listeners and all other objects, which reference the broadcaster should release the reference to the source. No method should be invoked anymore on this object ( including
XComponent.removeEventListener()).This method is called for every listener registration of derived listener interfaced, not only for registrations at
XComponent.- Parameters:
event (EventObject) – Event data for the event.
Source (com.sun.star.lang.EventObject) –
- Return type:
None
- submitting(event)[source]
Is invoked when a component, at which the listener has been registered, is about to submit its data.
If event is canceled and the cancel args are not handled then a
VetoExceptionwill be raised.- Parameters:
event (EventObject) – Event data for the event.
- Raises:
com.sun.star.util.VetoException –
VetoException- Return type:
None
Note
When
submittingevent is invoked it will contain aCancelEventArgsinstance as the trigger event. When the event is triggered theCancelEventArgs.cancelcan be set toTrueto cancel the submission. Also if canceled theCancelEventArgs.handledcan be set toTrueto indicate that the submission should be performed. TheCancelEventArgs.event_datawill contain the originalcom.sun.star.lang.EventObjectthat triggered the update.Also the
CancelEventArgscan set amessagevalue that will be used as the message for theVetoException.If the
event.set("skip_veto_exception", True)is set then theVetoExceptionwill not be raised. This is probably not a good idea but it is there if you need it.The following example shows how to use the
CancelEventArgsto cancel the submission of data.def on_submitting(src: Any, event: CancelEventArgs) -> None: if not validate_data(): event.cancel = True event.set("message", "Canceling due to data validation fail.")