Skip to content

Instantly share code, notes, and snippets.

@cameroncf
Created July 24, 2014 14:06
Show Gist options
  • Save cameroncf/01763fa8b9cfe1efa371 to your computer and use it in GitHub Desktop.
Save cameroncf/01763fa8b9cfe1efa371 to your computer and use it in GitHub Desktop.
component
output = 'false'
accessors = 'true'
{
/* ENTITY SPECIFIC */
property name='messageType' type ='string';
property name='messageTitle' type ='string';
property name='messageText' type ='string';
/*** CONSTRUCTOR ********************************************************************************/
public UIMessage function init(string messageType='', string messageTitle='',string messageText='',struct messageData=structNew()) output = 'false' {
variables.messageType = arguments.messageType;
variables.messageTitle = arguments.messageTitle;
variables.messageText = arguments.messageText;
return this;
}
}
component
output = 'false'
{
public UIMessageFacade function init() output = 'false'
{ return this; }
public struct function getMessage(required string type) output = 'false' {
if (hasMessage(arguments.type)) {
return session.uimessages[arguments.type];
} else {
return '';
}
}
public void function setMessage(required UIMessage message) output = 'false' {
session.uimessages[arguments.message.getMessageType()]= arguments.message;
}
public boolean function hasMessage(required string type) output = 'false' {
if (not isDefined('session') or not structKeyExists(session,'uimessages') or not structKeyExists(session.uimessages, arguments.type)) {
return false;
} else {
return true;
}
}
public void function reset(string type='') output = 'false' {
if (structKeyExists(session,'uimessages') and
len(trim(arguments.type)) and
structKeyExists(session.uimessages,arguments.type)) {
structDelete(session.uimessages,arguments.type);
} else {
structDelete(session,'uimessages');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment