models/ContactService.cfc
with a getAll()
method and a companion unit test at tests/specs/unit/ContactServiceTest.cfc
. Let's open the model object:singleton
annotation on the component tag. This tells WireBox that this service should be cached for the entire application life-span. If you remove the annotation, then the service will become a transient object, which means that it will be re-created every time it is requested.install mockdatacfc
handler/contacts.cfc
handler with an index()
action, the views/contacts/index.cfm
view and the accompanying integration test tests/specs/integration/contactsTest.cfc
.property
that will have a reference to our model object.inject
annotation on the property
definition. This tells WireBox what model to inject into the handler's variables
scope.models
folder for the value, which in our case is ContactService
. Now let's call it and place some data in the private request collection prc
so our views can use it.prc
struct as aContacts
, let's display it to the screen using ColdBox's HTML Helper.contacts/index.cfm
and add the following to the view:singletons
, they will persist for the life-span of your ColdFusion application. To see code changes for singletons, you have to reinit the framework by using the ?fwreinit={password}
Url action or via CommandBox using coldbox reinit
. Please check out the API Docs to discover CommandBox: [https://apidocs.ortussolutions.com/commandbox/5.2.0/index.html]http://localhost:{port}/contacts/index
and view the nice table of contacts being presented to you.