Calling functions inside DAO.cfc from GW.cfc

22 views
Skip to first unread message

Clifford Moon

unread,
Feb 26, 2013, 11:02:34 AM2/26/13
to model...@googlegroups.com
Greetings,

I have several functions inside the WFGW.cfc file that I'm interested in calling from WFDAO.cfc  (both located in the MODEL directory).  

All are defined inside coldspring.xml, but I cant seem to be able to recognize those functions from WFDAO.cfc.

Here is my bean definition inside cold spring.xml:

<bean id="WFBean" class="it.workflow.model.WFBean" singleton="true" />

<bean id="WFService" class="it.workflow.model.WorkFlowService">

        <property name="WFDAO"><ref bean="WFDAO" /></property>

        <property name="WFGW"><ref bean="WFGW" /></property>        

</bean>

<bean id="WFDAO" class="it.workflow.model.WFDAO">

   <property name="AppConfig"><ref bean="AppConfig" /></property>

</bean>

<bean id="WFGW" class="it.workflow.model.WFGW">

   <property name="AppConfig"><ref bean="AppConfig" /></property>

</bean>


What would I need to do to make those functions available?

Thanks for any help

Clifford Moon

Dan Skaggs

unread,
Feb 26, 2013, 11:08:16 AM2/26/13
to model...@googlegroups.com
My personal opinion is that there's no reason to split functions between a gateway object and a DAO object any more. Several years ago I started putting the functions from both those types of objects into one object I called a "Manager" object (for instance WFManager.cfc). At that point you don't have to worry about trying to get across to the GW from the DAO because all the functions are in the same CFC.

That requires a slight refactoring of your WFService object but in my opinion is preferable because it's the more pragmatic way of building things and not as strict to what used to be a "best practice".

YMMV. Just my 2 cents.

Dan

--
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
 
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en
---
You received this message because you are subscribed to the Google Groups "model-glue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to model-glue+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Matt Quackenbush

unread,
Feb 26, 2013, 11:17:04 AM2/26/13
to model...@googlegroups.com
I agree with Dan. In a practical application, as Dan mentioned, there is no reason for both the Gateway and DAO patterns to be employed. Because of this, I personally use the terms "gateway" and "DAO" interchangeably. Whatever you want to call it, abstract your persistence mechanism away in a single class/object, and call it a day. Infinitely more maintainable and usable. No fuss, no muss.

Clifford Moon

unread,
Feb 26, 2013, 11:39:21 AM2/26/13
to model...@googlegroups.com
Hi,

Thanks for the quick reply and I'll use this mechanism from this point forward.

Have a great day

Cliff

Clifford Moon

unread,
Feb 26, 2013, 11:41:04 AM2/26/13
to model...@googlegroups.com
Thanks Matt,


- Cliff

Dan Wilson

unread,
Feb 26, 2013, 11:55:47 AM2/26/13
to model...@googlegroups.com
Clifford,
I'm going to answer your original question, because I believe it would be instructional. While I don't personally split persistence in two objects, there is nothing specifically wrong with it if that's what you want to do.

Step1: Update WFDAO.cfc to have get/setWFGW functions.

Step 2: Update ColdSpring.xml

<bean id="WFBean" class="it.workflow.model.WFBean" singleton="true" />

<bean id="WFService" class="it.workflow.model.WorkFlowService">

        <property name="WFDAO"><ref bean="WFDAO" /></property>

        <property name="WFGW"><ref bean="WFGW" /></property>        

</bean>

<bean id="WFDAO" class="it.workflow.model.WFDAO">

   <property name="AppConfig"><ref bean="AppConfig" /></property>

   <property name="WFGW"><ref bean="WFGW" /></property>  <!-- Pass in the object -->

</bean>

<bean id="WFGW" class="it.workflow.model.WFGW">

   <property name="AppConfig"><ref bean="AppConfig" /></property>

</bean>

 


Step 3: Call the gateway functions inside your DAO, getWFGF().someGatewayFunction()



DW



Tuesday, February 26, 2013 11:02 AM
Reply all
Reply to author
Forward
0 new messages