1

All of my FW/1 controllers extend extend base.cfc. In base.cfc there is a function called addMessage(). Messages are thing like "You have successfully logged in". "There is an error in your data", "Error occurred while processing request.

The addMessage() appends messages to a variable called request.arMessage (an array). When I get to the layout file, the layout file loops through all the message and displays them on the page.

I am considering replacing request.arMessage with request.qryMessage. That way I can run a QoQ and sort by severity as opposed to last in last out. See below

void function addMessage(required string message, numeric priority=0) output="false"    {

param request.qryMessageQueue = QueryNew("Priority,Message", "integer,varchar");

QueryAddRow(request.qryMessageQueue);
QuerySetCell(request.qryMessageQueue, "Priority", arguments.priority);
QuerySetCell(request.qryMessageQueue, "Message", trim(arguments.message));
}

Is this approach consistent with how MVC and FW/1 should be doing this?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72

1 Answers1

0

I can't speak for the requirements of MVC or FW/1, but I can tell you how to do this is your cfc.

Instead of building an array, build a query object. Then use your Q of Q to sort it. Then use a combination of ListToArray and ValueList to create your sorted array.

Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43