TVScoundrel/coldbox-platform — comment on commit 9358ed66f41faaf0fa36d7160c0e97c9739c2d91
File:  line 0
By TVScoundrel:

1. info(): allowed types are info|warning|error
2. append(): allowed types are info|warning|error
3. appendArray(): allowed types are info|warning|error
4. prependArray(): method added as the counter part of appendArray()

5. putData(): method to add a data array of structs to the flash memory when validating forms
6. addData(): wrapper for putData to append key - value pairs to the data array in flash
7. getData(): method to get the key - value pair structs from the flash
8. getDataJSON(): wrapper to get the data array from flash in JSON format
--> instance.flashDataKey = "coldbox_plugin_messagebox_data" is used as flashKey for the data array.

-- uses --
// in CF we validate a form and find a few fields with missing data:
messageBox.setMessage(type="error",message="Following values are required");

// for instance form field companyName is required but it is empty:
messageBox.addData(key = "companyName", value = "Value is required");
// for instance form field companyVAT is required but it is empty:
messageBox.addData(key = "companyVAT", value = "Value is required");

(in javascript)
var messageData = #getPlugin("messageBox").getJSON()#;

// will result in:
// var messageData = [{"KEY":"compamyName","VALUE":"Value is required"},{"KEY":"compamyVAT","VALUE":"Value is required"}];

// using JQuery for example
function addFormMessages() {
$.each(messageData, function() {
$('#'+this.KEY).addClass('invalid');
$('#'+this.KEY+'Message').html(this.VALUE);
});
}

so in the first loop:
$('#companyName') will get class 'invalid' and
$('#companyNameMessage') will get html = 'Value is required'
etc...