Can i used entityService on views?

in handler, i can used

property name = “productService” inject =“entityService:product”;

and in views, can i used entityService?
Examples:

Sure, you can use whatever services/models you want. Since views aren’t a component, you can’t use the mixin style of injection that uses cfproperties. Instead, just ask WireBox for whatever you want like so:

getInstance( dsl=“entityService:product” )

Now, if you have already injected that into your handler, you can also just pass it along to your view by placing it in the private request collection like so:

in your handler method:

prc.productService = productService;

In your view.

prc.productService.doSomething()

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

You can, but you want to decouple it from views. Main reason is that, outside of a view is the best way to reuse code.

Hi Brad

If I use

`
getInstance( dsl=“entityService:product” )

`

without injecting first any where , will injection be done automatically and a valid instance is returned ?

Thanks
Brahmaiah

“injection” only applies to CFCs. When you call getintsance() in a view, you’re just asking WireBox to return an instance of that object and it’s up to you to use it or store it if you wish. WireBox will build the instance if it’s not been created before, and/or return it from its scope if it’s not a transient.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com