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
,XSubmissionVetoListener
Is 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.XSubmission
interface. 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
VetoException
will be raised.- Parameters:
event (EventObject) – Event data for the event.
- Raises:
com.sun.star.util.VetoException –
VetoException
- Return type:
None
Note
When
submitting
event is invoked it will contain aCancelEventArgs
instance as the trigger event. When the event is triggered theCancelEventArgs.cancel
can be set toTrue
to cancel the submission. Also if canceled theCancelEventArgs.handled
can be set toTrue
to indicate that the submission should be performed. TheCancelEventArgs.event_data
will contain the originalcom.sun.star.lang.EventObject
that triggered the update.Also the
CancelEventArgs
can set amessage
value that will be used as the message for theVetoException
.If the
event.set("skip_veto_exception", True)
is set then theVetoException
will 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
CancelEventArgs
to 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.")