[coldbox-3.5.1] Accessing Services in View

No, I’m not trying to break MVC rules…just debugging / learning

So I’ve wired my first service/dao/model (yeah Mike). I tested using some examples online (videos, etc.) and injected the wirebox properties into my entity object, which was totally unnecessary, but I might like to have them available at the service level.

So, I moved the property out of the class and into the service which of course works…but I’d like to be able to dump the instance settings of the service in my view and I don’t know / cannot seem to find out, how to access the implicitly created service object instance from the handler in the view.

I guess the more generalized question, as I’m trying to learn these intricacies, is how, at any point in the request, do I easily access injected material, typically I would imagine in the handler, in the view…at least in places where it is not possible to “pass” said injected material around?

Mike

It sounds like you’re trying to break an MVC rule. :slight_smile: Why does it seems necessary for your view to have instance settings of your service?

BTW, I imagine your controller is already making calls to one or more services. The results of those calls are probably being stored in the request context. The RC is available in the view. So why can’t your controller ask the service for these settings and store them in the RC for the view?

Jason Durham

I love that the first post points out the MVC rules being broken anyway…some rules should not be broken and I want to stay strong regarding MVC.

I’m just learning CB really and I still have some “instinctive” habits when it comes to quick debugging…one if which is just dump what I’m curious about in my view. There is still some “magic” to CB I’m trying to learn about…just can agree with “it happens”…I gotta know why and how…what’s my scope, can I see this value, how do I get at “that” when it’s injected…etc.

I realize that I can take any payload, including the entire instance and stuff values into the request context (or private request context), it was just not my first instinct. I am definitely on target with what Brad posted (very very helpful to see that in electron form Brad).

Thanks for all the responses.

Mike