Charles Robertson
11/02/2022, 3:17 PMvariables
scope mutation inside a singleton.
I only used this approach, because I found it in an FW1 example application. And to be fair, the objective, within the example app, was very possibly correct and I corrupted it.
So, I’m going to remove the variables
scope variable and just return the list data from the page()
method.
Before:
function page(page){
// build variables.blogs struct from DB query
…
cfloop(query=local.qGetFile, startrow=local.startrow, endrow=local.endrow){
// add blog bean to variables.blogs
…
variables.blogs[local.qGetFile.File_ID] = blog;
}
}
After:
function page(page){
// build variables.blogs struct from DB query
…
local.pagedata = {
recordcount: local.recordcount,
list: {}
};
cfloop(query=local.qGetFile, startrow=local.startrow, endrow=local.endrow){
// add blog bean to variables.blogs
…
local.pagedata.list[local.qGetFile.File_ID] = blog;
}
return local.pagedata;
}