Search the site

In the 2.31 release of Dimac ScriptServer, a notification system based on scriptlets is introduced.

In short, certain system scripts, such as editors, will call methods in a predefined scriptlet to make the site aware of important events.

These event can of course be used for logging, but also as a mechanism for changing default behaviour.

In order to benefit from events the following steps must be taken:

For application wide event triggers, make sure a scriptlet exists in your application named ApplicationNotifications. For template specific event triggers, just add the method to your template.

The following list of notifications regards client side edit forms from FieldEdit and LiveEdit:

  • NotifyBeforeEditHTML(key)
    This event is called just before a client side form is rendered for document editing
  • NotifyEditHTML()
    This event is called from within the rendering of the form element
  • NotifyAfterEditHTM()
    This event is called just after a client side form is rendered for document editing
  • NotifyAfterDocumentDeleted()
    This event is called from the page displaying confirmation on having deleted a document

The first 3 above notifications may render client side scripts that refers to a form named 'EditForm'. The form tag includes input element for nearly all document properties as well as the fields.

It's also possible to override how posting is done - just implement a boolean valued function on the client side named OnSubmitEditForm.

The last notification is called from the page that performs the deletion of a document and then displays a message about it.

// in a scriptlet document belonging to ApplicationNotifications
function NotifyBeforeEditHTML(key)
{
    // Save the key on the client side
    <script language="JavaScript">
        var g_DocumentKey = '<%=key%>';
    </script>
}
function NotifyAfterEditHTML()
{
    // Put some client side scripts
    <script language="JavaScript">
        return window.confirm('Do you want to save the document with key ' + g_DocumentKey);
   
</script>
}

The following list of notifications regards server side updating of (edited) documents:

  • NotifyBeforeDocumentSaved()
    This event is called just before a document is about to be updated.
    No output to the client is sent yet and no modifications to the document is done.
  • NotifyAfterDocumentSaved(doc,redirectURL)
    This event is called after a document's properties is updated. To prevent redirection to the url specified, you can issue a Response.End() or a Response.Redirect(...).

Saving of documents, and thus calling of the above notifications, are done in \SiteEditor\EditorSave. EditorSave only updates a document's properties and fields given form data and then issues a redirect.

 




Published by: 0