<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:clearspace="http://www.jivesoftware.com/xmlns/jive/rss" version="2.0">
  <channel>
    <title>Adobe Community: Message List - Created a Global UDF but don't know how to call it, please assist</title>
    <link>https://forums.adobe.com/community/coldfusion/coldfusion_getting_started?view=discussions</link>
    <description>Most recent forum messages</description>
    <language>en</language>
    <pubDate>Wed, 06 Aug 2014 19:46:28 GMT</pubDate>
    <generator>Jive Engage 7.0.0.1  (http://jivesoftware.com/products/)</generator>
    <dc:date>2014-08-06T19:46:28Z</dc:date>
    <dc:language>en</dc:language>
    <item>
      <title>Re: Created a Global UDF but don't know how to call it, please assist</title>
      <link>https://forums.adobe.com/message/6617834?tstart=0#6617834</link>
      <description>&lt;!-- [DocumentBodyStart:65410588-6d9c-4b1f-9803-d28c08c19dfe] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;Based on that code, you would refer to it as "URL.UDF.getMessage()".&amp;nbsp; &lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Where does the line "&lt;span style="color: #333333; font-family: adobe-clean, 'Helvetica Neue', Arial, sans-serif;"&gt;cfset structAppend(url,createObject( "component", "UDF" ))&lt;/span&gt;" actually occur inside Application.cfc (above any function definitions or inside one of the functions)?&amp;nbsp; If it's at the top of the component definition, that UDF gets instantiated on each request and put in that page's URL scope.&amp;nbsp; Does the UDF component maintain state in any way?&amp;nbsp; If not, and you make sure all of its methods are thread-safe, I would just store it in the application scope like this:&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;lt;cfset application.UDF = createObject("component","UDF")&amp;gt;&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Put that in your onApplicationStart() method in Application.cfc so that it is only instantiated once.&amp;nbsp; Then call it's methods from anywhere in your application as "application.UDF.getMessage()".&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-Carl V.&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:65410588-6d9c-4b1f-9803-d28c08c19dfe] --&gt;&lt;img src='/beacon?t=1415920249623' /&gt;</description>
      <pubDate>Wed, 06 Aug 2014 19:46:28 GMT</pubDate>
      <author>forums_noreply@adobe.com</author>
      <guid>https://forums.adobe.com/message/6617834?tstart=0#6617834</guid>
      <dc:date>2014-08-06T19:46:28Z</dc:date>
      <clearspace:dateToText>3 months 1 week ago</clearspace:dateToText>
      <clearspace:objectType>0</clearspace:objectType>
    </item>
    <item>
      <title>Created a Global UDF but don't know how to call it, please assist</title>
      <link>https://forums.adobe.com/message/6617643?tstart=0#6617643</link>
      <description>&lt;!-- [DocumentBodyStart:dd480e43-023e-43a5-b147-185d2ada7d9e] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;I created a cfcomponent and a bunch functions inside it.&amp;nbsp; One of the function needs to call a process that is also needed by other part of the application. Since this "process" is needed in a different parts of the application, I decided to make this "process"&amp;nbsp; a global function that can be called from any part of the application. I found a blog from Ben Nadel that explained exactly what I need. But the problem is I don't quite understand how to call the globa UDF, his explanation is not clear to me. Ben created UDF.cfc:&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfcomponent&amp;nbsp; output="false"&amp;nbsp; hint="I define the application settings and event handlers.&amp;nbsp; &lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cffunction name="getMessage" access="public" returntype="string" output="false" hint="I return a test message."&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- Here is where I wrote the process needed by different parts of the application --&lt;br/&gt; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfreturn "I am defined in the UDF component" &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cffunction&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfcomponent &lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; On the Application.cfc he created a URL scope:&amp;nbsp; cfcomponent output="false"&amp;nbsp; hint="I define the application settings and event handlers."&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Define the application:&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfset this.name = hash( getCurrentTemplatePath() ) &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfset this.applicationTimeout = createTimeSpan( 0, 0, 5, 0 ) &lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add all of our "global" methods to the URL scope. Since&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ColdFusion will automatically seach the URL scope for&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; non-scoped variables, it will find our non-scoped method&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names: &lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfset structAppend(url,createObject( "component", "UDF" )) &lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cfcomponent&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The part that I don't understand is, how to call getMessage method? Is it: application.cfc.UDF.getMessage(parameter1,parameter2) ??&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:dd480e43-023e-43a5-b147-185d2ada7d9e] --&gt;</description>
      <pubDate>Wed, 06 Aug 2014 19:01:25 GMT</pubDate>
      <author>forums_noreply@adobe.com</author>
      <guid>https://forums.adobe.com/message/6617643?tstart=0#6617643</guid>
      <dc:date>2014-08-06T19:01:25Z</dc:date>
      <clearspace:dateToText>3 months 1 week ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
    </item>
  </channel>
</rss>

