com.sebtools Build 12 Documentation: NoticeMgr.cfc

NoticeMgr.cfc

NoticeMgr.cfc uses Mailer.cfc and DataMgr to allow the system to send out dynamic messages that can be edited with a user interface (which is not provided by the component).

Instantiate

NoticeMgr.cfc requires both Mailer.cfc and DataMgr to be passed into the "init" method during instantiation (to the "Mailer" and "DataMgr" arguments respectively).

Use

In order to use NoticeMgr, it must be passed in to any component that will use it.

<cffunction name="init" access="public" returntype="any" output="no">
  <cfargument name="NoticeMgr" type="any" required="yes">
 
  <cfset variables.NoticeMgr = arguments.NoticeMgr>
  
  <cfreturn this>
</cffunction>

Create

A notice should then be created from the component (a user should not have the ability to create a notice as code would need to be written to cause it to be sent out in response to the appropriate action).

For example (Text argument for text-only email, HTML argument for HTML email, both for multipart):

<cfset variables.NoticeMgr.addNotice(
	Component='ContactOMatic',
	Name='Contact Saved',
	Subject='A Contact was Saved',
	DataKeys='ContactName',
	Text='A contact ("[ContactName]") was saved.'
)>

Or you could use the cf_NoticeMgr custom tag (action of "addText" for text-only email or "addHTML" for HTML email):

<cf_NoticeMgr
	action="addText"
	Component="ContactOMatic"
	Name="Contact Saved"
	Subject="A Contact was Saved"
	DataKeys="ContactName">
A contact ("[ContactName]") was saved.
</cf_NoticeMgr>

Note that, in either event, NoticeMgr will only take action if the notice does not already exist for this component. If, however, a notice of the same name exists for a different component then NoticeMgr will throw an error to alert of the conflict.

The "Component" argument need only be a unique string identifying that component.

Send

After that sending a notice requires using the "sendNotice" method:

<cfset sData = {ContactName="Jim Smith"}>
<cfset variables.NoticeMgr.sendNotice("Contact Saved",sData)>

Edit

To change the contents of a notice, use the "saveNotice" method:

<cfset sData = {Text='A contact ("[ContactName]") was just saved.'}>
<cfset variables.NoticeMgr.saveNotice("Contact Saved",sData)>

Note that calling "addNotice" again will not supercede changes made by "saveNotice" (or directly in the database) even if NoticeMgr has been instantiated since the change.

CFC Docs

Blog Entries