Just wondering if anyone knows of a setting on CF2...
# cfml-general
j
Just wondering if anyone knows of a setting on CF2021 that prevents access to Static variables? We have an object with a a static () in it, and this works fine via CommandBox, but not on the actual server
Copy code
SomeObject::staticVarName = getStuffFromDB(datasourceParams);
Copy code
Illegal access to package variable
b
I think this is "illegal" because
getStuffFromDB
is not static. Also, with static, you have to use the component-name, not "some object" instantiated from the component. That is, something like
// here getStuffFromDB is a static method of the component
varName = ComponentName::getStuffFromDB(datasourceParams);
j
In case anyone ever finds this, it was due to public/private not being specified for the static variable - the syntax is otherwise fine
Copy code
static {
        public statusNames = {
            "A": "Test 1",
            "B": "Test 2",
            "C": "Test 3"
            
        }