Entries for month: December 2009
Setting up Remote Service for AJAX Call in CF with Coldspring
Posted by Erik Ruthven in Coldfusion on December 22, 2009
A very simple example of using the remote service in Coldspring. This snippet is from my Coldspring.xml, or wherever you are defining your Coldspring beans. Simply create another bean, just like your Service layer, Gateway layer, and DAO Layer. Next, create a folder called /Remote in the project root, and point the property name="relativePath" inside your newly created RemoteService bean to the /Remote folder. This is where the generated remote service CFCs will live. Then, change the property Name="target", to be the CFC you want Coldspring to create a remote CFC of. The property name="serviceName" will be the name of the generated remote CFC. More explanations of using Coldspring Remote Services here.
<!-- School --> <bean id="SchoolService" class="model.Service.SchoolService"> <constructor-arg name="SchoolGateway"><ref bean="SchoolGateway" /></constructor-arg> <constructor-arg name="SchoolDAO"><ref bean="SchoolDAO" /></constructor-arg> <constructor-arg name="ResultService"><ref bean="ResultService" /></constructor-arg> <constructor-arg name="UtilityService"><ref bean="UtilityService" /></constructor-arg> <constructor-arg name="SessionFacadeService"><ref bean="SessionFacadeService" /></constructor-arg> </bean> <bean id="RemoteSchoolService" class="coldspring.aop.framework.RemoteFactoryBean" lazy-init="false"> <property name="target"><ref bean="SchoolService" /></property> <property name="serviceName"><value>RemoteSchoolService</value></property> <property name="relativePath"><value>/remote/</value></property> <property name="remoteMethodNames"><value>*</value></property> </bean> <bean id="SchoolGateway" class="model.Gateway.SchoolGateway"> <constructor-arg name="dsn"><ref bean="dsn" /></constructor-arg> <constructor-arg name="reactor"><ref bean="ormService" /></constructor-arg> </bean> <bean id="SchoolDAO" class="model.DAO.SchoolDAO"> <constructor-arg name="dsn"><ref bean="dsn" /></constructor-arg> <constructor-arg name="reactor"><ref bean="ormService" /></constructor-arg> </bean>
How to Find Table/Column in SQL Server
Posted by Erik Ruthven in SQL on December 22, 2009
Ever needed to find a table on a db server?, not sure where it could be? Use this to search the SQL Server to find the table you need.
select * from information_schema.tables where table_name like '%Navigation%'
Here is how to find a column:
select * from information_schema.columns where column_name like '%NavigationId%'
CFGroovy + Hibernate + Coldspring Part 2
Posted by Erik Ruthven in Coldfusion on December 22, 2009
This is the second post on configuring CFGroovy with Hibernate and Coldspring. This post will focus on configuring Coldspring and injecting the necessary cfcs. The following xml beans go inside the Coldspring.xml. In my setups I just create a file called Database.xml which is included in the Coldspring.xml. My Database.xml, basically has all my beans with the injected cfcs, this isn't necessary i just find it more clean and organized.
This bean calls the configure() in thje cfgroovy engine, then later tells it that we want to include the cfhibernate plugin. If you wanted to just use Groovy in CF, you would leave out the cfhibernate ref bean.
<bean id="cfgroovy" class="cfgroovy.engine.cfgroovy" init-method="configure"> <property name="path"> <value>cfgroovy/engine/</value></property> <property name="plugins"> <list> <ref bean="cfhibernate" /> </list> </property> </bean>
This is the actual bean for cfhibernate, here we specify the DSN (plugin your DSN..), the path for entities (which we will talk about later), and the classes (db tables in this case).
<bean id="cfhibernate" class="cfgroovy.engine.hibernatePlugin">
<property name="entityPath">
<value>${entityPath}</value>
</property>
<property name="coldFusionDsn">
<value>YOUR_CF_DSN</value>
</property>
<property name="annotatedClasses">
<list>
<value>blog_entry</value>
<value>blog_post</value>
</list>
</property>
</bean>
The next post will dive into adding the necessary code to application.cfm, the complicated part.......