Developing a Global Messaging Notification Object

For a while now I have been using Redballoon's Messaging Custom Tag however I find creating the messages at the VIEW level messy and hard to track down, especially when the VIEW level is not where validation and results happen. So after a fair amount of thinking and talking with my co-workers I developed a messaging object that gets passed into the controller and has the ability to sets messages like this anywhere within the controller. But only in the controller.

messageHelper.addMessage("error", "Please Choose a number of students above 0");

Now all I do is push this entire object back to the view and handle it in the main template via a custom tag.

messages = viewstate.getValue("messageHelper");
   
   <!--- html code --->

This is an abstract from the custom tag that deals with the message object.

oMsg.clearMsgs();

#aErrors[j]#

Just a quick note that the oMsg.clearMsgs(); is highly important especially when dealing with model-glue. All it does is clear the error array after the messages have been prepared for the UI so they won't build up with every user action with the old messages!

Now all you need to do is make the class error look hot... I personally am very satisfied with blueprint which has the class and much much more built into it. But will leave that for another entry.

0 comments

0 responses to “Developing a Global Messaging Notification Object”

Leave a comment