Events
Configuring event handlers in Umbraco UI Builder.
Umbraco UI Builder triggers different notification events during operation, allowing customization of default behavior.
Registering Event Handlers
Umbraco UI Builder follows the Umbraco Notification mechanism for event registration.
Define a notification event handler for the target event:
Register the event handler in Program.cs
:
Repository Events
Using the EntitySavingNotification()
EntitySavingNotification()
Triggers when Save
is called before persisting the entity. The notification contains an Entity
property with Before
and After
values, providing access to the previous and updated entities. Modify the After
entity to persist changes. If the Cancel
property of the notification is set to true
then the save operation will be canceled and no changes will be saved.
Example
Using the EntitySavedNotification()
EntitySavedNotification()
Triggers when the repository Save
method is called and after the entity has been persisted. The notification contains an Entity
property with Before
and After
inner properties. These properties provide access to a copy of the previously persisted entity (or null if a new entity) and the updated entity that´s saved.
Example
Using the EntityDeletingNotification()
EntityDeletingNotification()
Triggers when the repository Delete
method is called and before the entity is deleted. The notification contains an Entity
property providing access to a copy of the entity about to be deleted. If the Cancel
property of notification is set to true
then the delete operation will be cancelled and entity won't be deleted.
Example
Using the EntityDeletedNotification()
EntityDeletedNotification()
Triggers when the repository Delete
method is called and after the entity has been deleted. The notification contains an Entity
property providing access to a copy of the entity that´s deleted.
Example
Using the SqlQueryBuildingNotification()
SqlQueryBuildingNotification()
Triggers when the repository is preparing a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object, and the where clause/order by clauses. These will be used to generate the SQL query.
Example
Using the SqlQueryBuiltNotification()
SqlQueryBuiltNotification()
Triggers when the repository has repaired a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object and the where clause/order by clauses that was used to generate the SQL query.
Example
Repository Events Validation
From version 15.1.0
, complex server-side validation can be added to a collection using the CancelOperation
method of the notification.
Example
Last updated
Was this helpful?