Wiki
Clone wikijummp / notifications
Jummp's layout pages include a notification mechanism that can be used to give users messages related, for instance, to status updates and errors in submissions. This is a functionality that is used often, and is therefore factored out and implemented in the following elements:
_showNotificationDiv.gps
- included in each component template of the layout, places the notification div in the pagenotification.js
- Responsible for showing (and after a short delay, hiding) the notificationnotification.css
- Responsible for styling the notification
Notifications can be included in the page on the server side and the browser side. An example of this notification can be seen below.
Server-Side Notification Generation
Notifications on the server side can be generated by setting a variable with the name flashMessage
when the controller passes control to the GSP. This may be a part of the model, or included in the flash memory. The variable is expected to be a string. The notification mechanism checks if there is an i18n code defined corresponding to the string, in which case that text is displayed, otherwise the string is displayed directly. If this string is not present, the notification mechanism looks to use the grails validation error client-side reporting mechanism, as described here. An object (whether command or domain) failing validation can be passed to the GSP with the name validationErrorOn
. The errors are rendered with the gsp tag renderErrors. If neither of these variables is defined, the notification div is hidden, allowing client side notifications to use it.
Client-Side Notification Generation
Certain pages, for instance those in the user administration pages, perform processing using AJAX queries, and need to display processing results. This can be accomplished using the showNotification
function defined in notification.js
. The function displays the text provided, and schedules hiding it after a small delay.
Updated