Project Pods - robjshaw tag:www.projectpods.com,2008:/projectpods/ Mango 1.1 Developing a Global Messaging Notification Object urn:uuid:E33C47CC-3048-79ED-99E34E18121CB982 2008-07-02T03:07:23Z 2008-07-02T03:07:02Z Rob Shaw <p>For a while now I have been using <a title="Redballoon's Messaging Custom Tag" href="http://labs.redbd.net/projects/msgHandler.cfm">Redballoon's Messaging Custom Tag</a> 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.</p> <p> <code>messageHelper.addMessage(<span class='cc_value'>&quot;error&quot;</span>, <span class='cc_value'>&quot;Please Choose a number of students above 0&quot;</span>);</code></p> <p>Now all I do is push this entire object back to the view and handle it in the main template via a custom tag.</p> <p> <code>messages = viewstate.getValue(<span class='cc_value'>&quot;messageHelper&quot;</span>);<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;<span class='comment'>&lt;!--- html code ---&gt;</span></code></p> <p>This is an abstract from the custom tag that deals with the message object.</p> <p> <code>oMsg.clearMsgs();</code></p> <div class="error"> <p>#aErrors[j]#</p> </div> <p>Just a quick note that the <em>oMsg.clearMsgs();</em> 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!</p> <p>Now all you need to do is make the class <em>error</em> look hot... I personally am very satisfied with <a title="Awesome CSS Framework" href="http://code.google.com/p/blueprintcss/">blueprint</a> which has the class and much much more built into it. But will leave that for another entry.</p>