ColdBox and ColdSpring Hard Lessons
It has been a few weeks now of me getting to grips with ColdBox and ColdSpring. My question has been mainly on why I would use ColdSpring at all. Some will be glad to hear I am starting to see how ColdSpring helps with managing CFC's. I also just wanted to recommend Jason Dean's Blog. He has provided a very insightful step by step guide to using ColdBox and ColdSpring which has really helped me. I got it late, I know but if for some strange reason you have not read his series, do it, do it now!
The Hard Lesson
When I was creating my object i.e "userservice().init()" CF was throwing an error. It seemed ColdSpring knew nothing about my injected properties to the CFC, can you spot why? Well either ColdSpring or ColdBox (not sure which) handles the .init() it calls the constructor and passes in the correct argument without my help. So because I was trying to call the init() myself it was not being managed by ColdSpring. Simple, but it held me up for a long time. Because I always try and follow the best practice it never occurred to me this could be the culprit. A quick post on the ColdSpring user group and Brian Kotek quickly put me on the right track, thanks again.
DNS, DNS, where are you?
All the examples I found online show injecting the DNS setting into a userGateway using a property in the actual coldspring.xml config file. However my DNS setting are already in my coldbox config file so why repeat it again! No need! Coldbox has made it easy to create a bean and inject that too, cool!
2 <bean id="coldboxFactory" class="coldbox.system.extras.ColdboxFactory" />
3 <!--Create Config Bean-->
4 <bean id="ConfigBean" factory-bean="ColdboxFactory" factory-method="getConfigBean" />
5 <!--Create DNS Bean-->
6 <bean id="dsnBean" factory-bean="ColdboxFactory" factory-method="getDatasource">
7 <constructor-arg name="alias">
8 <value>DBDetails</value>
9 </constructor-arg>
10 </bean>
11 <bean id="adminUsersGateway" class="salesMaxx.model.adminUsersGateway">
12 <!--Gateway Bean needs DNS to be injected from DNS Bean!-->
13 <constructor-arg name="dsnBean">
14 <ref bean="dsnBean" />
15 </constructor-arg>
16 </bean>
17 <bean id="adminUsersService" class="salesMaxx.model.adminUsersService">
18 <property name="adminUsersGateway">
19 <ref bean="adminUsersGateway" />
20 </property>
21 </bean>
22 </beans>
Things I have found awesome (so far)
Finding out I no longer need to create an object! Yes ColdBox has an Autowire Interceptor for allowing you to set up dependency injection for handlers, plugins and interceptors, thats simple but cool!
To be continue when I get more time to play!




There are no comments for this entry.
[Add Comment] [Subscribe to Comments]