cbmessagebox

Class MessageBox

lucee.Component
    extended by cbmessagebox.MessageBox

Copyright Since 2005 Ortus Solutions, Corp www.ortussolutions.com --- This module provides a way to track alert message boxes. The user has several types of message types 1. Warn 2. Error 3. Info 4. Success The messages and optional metadata will be stored in the application's Flash RAM storage. --- The look and feel of the messages can be altered by styles and cfml template settings.

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Luis Majano
  •  
    Property Summary
    type property default serializable required
    any flash
          DI ***********************************************************.

    • access = public
    • returntype = any
    • inject = coldbox:flash
    true false
    string flashDataKey
          The flash data key to use in the flash RAM data struct.

    • access = public
    • returntype = any
    true false
    string flashKey
          The flash message key to use in the flash RAM data struct.

    • access = public
    • returntype = any
    true false
    string moduleRoot
          The module root location.

    • access = public
    • returntype = any
    true false
    boolean styleOverride
          Flag to override styles when rendering.

    • access = public
    • returntype = any
    false true false
    string template
          The default rendering template to use.

    • access = public
    • returntype = any
    true false
    Constructor Summary
    init(struct config)
          Constructor.
    Method Summary
    MessageBox addData(any key, any value)
         Add metadata that can be used for saving arbitrary stuff alongside our flash messages.
    MessageBox append(any message, [any defaultType='info'])
         Appends a message to the messagebox data.
    MessageBox appendArray(array messageArray, [any defaultType='info'])
         Append an array of messages to the MessageBox.
    MessageBox clearMessage()
         Clears the message structure by deleting it from the session scope.
    MessageBox error([any message=''], [array messageArray])
         Facade to setmessage with error type.
    private string flattenMessageArray(array messageArray, [string separator='
    '])
         Flatten a message array into a string with
    separators.
    array getData([boolean clearData='true'])
         Get the message data.
    string getDataJSON([boolean clearData='true'])
         Get the message data as js.
    string getFlash()
    string getFlashDataKey()
    string getFlashKey()
    struct getMessage()
         Returns a structure of the messages if it exists, else a blank structure.
    string getModuleRoot()
    string getStyleOverride()
    string getTemplate()
    boolean hasMessageType(string type)
         Returns true if the message box contains a message of specified type.
    MessageBox info([any message=''], [array messageArray])
         Facade to setmessage with info type.
    boolean isEmptyMessage()
         Checks wether the MessageBox is empty or not.
    private boolean isValidMessageType(string type)
         Validate a type.
    MessageBox prependArray(array messageArray, [any defaultType='info'])
         Prepend an array of messages to the MessageBox.
    MessageBox putData(array theData)
         WARNING: Override the entire flash metadata key with your own array of data.
    any renderIt([boolean clearMessage='true'], [any template=''])
         Renders the message box and clears the message structure by default.
    string renderMessage(any type, [any message=''], [any messageArray], [any template=''])
         Renders a messagebox immediately for you with the passed in arguments.
    any setFlash(any flash)
    any setFlashDataKey(string flashDataKey)
    any setFlashKey(string flashKey)
    MessageBox setMessage(any type, [any message=''], [array messageArray])
         Create a new MessageBox with a specific message and type.
    any setModuleRoot(string moduleRoot)
    any setStyleOverride(boolean styleOverride)
    any setTemplate(string template)
    MessageBox success([any message=''], [array messageArray])
         Facade to setmessage with success type.
    MessageBox warn([any message=''], [array messageArray])
         Facade to setmessage with warn type.
    MessageBox warning([any message=''], [array messageArray])
         Facade to setmessage with warn type.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(struct config)

    Constructor

    Parameters:
    config - The messagebox module configuration structure

    Property Detail

    flash

    property any flash

    DI ***********************************************************

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:flash
    serializable - true

    flashDataKey

    property string flashDataKey

    The flash data key to use in the flash RAM data struct

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    flashKey

    property string flashKey

    The flash message key to use in the flash RAM data struct

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    moduleRoot

    property string moduleRoot

    The module root location

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    styleOverride

    property boolean styleOverride = [false]

    Flag to override styles when rendering

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    template

    property string template

    The default rendering template to use

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    addData

    public MessageBox addData(any key, any value)

    Add metadata that can be used for saving arbitrary stuff alongside our flash messages

    Parameters:
    key - The key to store
    value - The value to store

    append

    public MessageBox append(any message, [any defaultType='info'])

    Appends a message to the messagebox data. If there is no message, then it sets the default type to info.

    Parameters:
    message - The message to append
    defaultType - The default type to use if not passed. Defaults to 'info'

    appendArray

    public MessageBox appendArray(array messageArray, [any defaultType='info'])

    Append an array of messages to the MessageBox. If there is no message, then it sets the default type to info.

    Parameters:
    messageArray - An array of messages to append
    defaultType - The default type to use if not passed. Defaults to 'info'

    clearMessage

    public MessageBox clearMessage()

    Clears the message structure by deleting it from the session scope.


    error

    public MessageBox error([any message=''], [array messageArray])

    Facade to setmessage with error type

    Parameters:
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.

    flattenMessageArray

    private string flattenMessageArray(array messageArray, [string separator='
    '])


    Flatten a message array into a string with
    separators

    Parameters:
    messageArray - The message array to flatten.
    separator

    getData

    public array getData([boolean clearData='true'])

    Get the message data

    Parameters:
    clearData - clear the data from flash or not.

    getDataJSON

    public string getDataJSON([boolean clearData='true'])

    Get the message data as js

    Parameters:
    clearData - clear the data from flash or not.

    getFlash

    public string getFlash()


    getFlashDataKey

    public string getFlashDataKey()


    getFlashKey

    public string getFlashKey()


    getMessage

    public struct getMessage()

    Returns a structure of the messages if it exists, else a blank structure.

    Returns:
    { type, message }

    getModuleRoot

    public string getModuleRoot()


    getStyleOverride

    public string getStyleOverride()


    getTemplate

    public string getTemplate()


    hasMessageType

    public boolean hasMessageType(string type)

    Returns true if the message box contains a message of specified type

    Parameters:
    type - The message type, available types are: success, info, error, warn

    info

    public MessageBox info([any message=''], [array messageArray])

    Facade to setmessage with info type

    Parameters:
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.

    isEmptyMessage

    public boolean isEmptyMessage()

    Checks wether the MessageBox is empty or not.


    isValidMessageType

    private boolean isValidMessageType(string type)

    Validate a type

    Parameters:
    type - The message type

    prependArray

    public MessageBox prependArray(array messageArray, [any defaultType='info'])

    Prepend an array of messages to the MessageBox. If there is no message, then it sets the default type to info.

    Parameters:
    messageArray - An array of messages to prepend
    defaultType - The default type to use if not passed. Defaults to 'info'

    putData

    public MessageBox putData(array theData)

    WARNING: Override the entire flash metadata key with your own array of data.

    Parameters:
    theData - The array of data to flash

    renderIt

    public any renderIt([boolean clearMessage='true'], [any template=''])

    Renders the message box and clears the message structure by default

    Parameters:
    clearMessage - Flag to clear the message structure or not after rendering. Default is true.
    template - An optional CFML template to use for rendering instead of core or setting

    renderMessage

    public string renderMessage(any type, [any message=''], [any messageArray], [any template=''])

    Renders a messagebox immediately for you with the passed in arguments

    Parameters:
    type - The message type, available types are: success, info, error, warn
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.
    template - The CFML template to use to render the messagebox, if not passed then the one set as default will be used.

    setFlash

    public any setFlash(any flash)

    Parameters:
    flash

    setFlashDataKey

    public any setFlashDataKey(string flashDataKey)

    Parameters:
    flashDataKey

    setFlashKey

    public any setFlashKey(string flashKey)

    Parameters:
    flashKey

    setMessage

    public MessageBox setMessage(any type, [any message=''], [array messageArray])

    Create a new MessageBox with a specific message and type

    Parameters:
    type - The message type, available types are: success, info, error, warn
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.

    setModuleRoot

    public any setModuleRoot(string moduleRoot)

    Parameters:
    moduleRoot

    setStyleOverride

    public any setStyleOverride(boolean styleOverride)

    Parameters:
    styleOverride

    setTemplate

    public any setTemplate(string template)

    Parameters:
    template

    success

    public MessageBox success([any message=''], [array messageArray])

    Facade to setmessage with success type

    Parameters:
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.

    warn

    public MessageBox warn([any message=''], [array messageArray])

    Facade to setmessage with warn type

    Parameters:
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.

    warning

    public MessageBox warning([any message=''], [array messageArray])

    Facade to setmessage with warn type

    Parameters:
    message - The message to flash, mutually exclusive to the 'messageArray' argument.
    messageArray - An array of messages to flash, mutually exclusive to the 'message' argument.