Often, Public Events won't fire and there will be no indication in the console or errors as to why. Here are some tips which may make it easier to figure out why your Public Event or other widget function isn't working.
Adding the listeners node into a dialog is easy, the listeners node can be of any type, such as nt:unstructured. For example, lets say I want to automatically set a hidden field called failureURL to the path of the page plus an extension. The resulting widget in the dialog.xml would look like this:
Can't find your code?
I like code formatting, it makes code easier to read and promotes consistency. Unfortunately, formatting your dialogs can cause issues. CQ does not seem to like when your dialog.xml has the namespaces on separate lines. When this happens, the dialog.xml will be evaluated as a file instead of a dialog definition and your dialog will not appear correctly. Undoing the formatting will fix the issue.
Do you have any other tips you've found useful? Please leave a comment!