My observation is that properties are defined like ‘Controller’, but they will never be set. They are only set in Variables.instance structure. Therefore they are always empty. That is understandable.
But what is surprising me is that following code below results in property undefined:
`
`
My questions are:
1.why the bean getter property is undefined even though accessors is set to true
2.Why the those properties are defined when they will never be set and always empty. E.g output from following code:
Hello Brahmaiah , and welcome to ColdBox! You don’t need to know about the internal workings of the request context to use the ColdBox framework. However if you’re just a curious person and want to understand it better, then feel free to look around in the code.
> why the bean getter property is undefined even though accessors is set to true
Do you mean the bean getter method? I see the getProperties() and getController() methods in a cfdump of “event” in Lucee, but perhaps Adobe CF doesn’t show generated accessors in the metadata.
> Why the those properties are defined when they will never be set and always empty.
Good question. It appears those properties aren’t actually used. “Controller” is stored in “variables.instance” and “properties” isn’t stored at all. rc and prc are also in variables.instance. Honestly, those properties might have been for the API docs, or perhaps they just got left there on accident. I do know that starting with ColdBox 4, Luis wanted to move to using actual properties and generated accessors for bean properties rather than the simulated “instance” scope which is sort of a nod to Java. Obviously we didn’t get everything refactored over to that style, but it’s possible Luis started to refactor this CFC and never completed it.
Is there something you’re trying to do with ColdBox that you are having trouble with related to these variables? If you want the rc, call event.getCollection() and if you want prc, call event.getPrivateCollection(). I rarely ever call those methods though, since the rc and prc variables are automatically made available in all handlers, views, and layouts. If you want access to the controller in any view, layout, or handler, just call the getController() method that’s made available to you.
Do not use the event.getController() method as it looks like it’s there on accident. Just use getController() by itself in handlers, view, and layouts. If you need the controller in a model (service, bean, dao, etc) then ask WireBox to inject it for you with the following property: