UDF file in Model Glue
This has just came up on the MG Lists and I thought i should post my solution on how I implement a UDF file in MG
1)My UDF file is a component (cfc) on the root of the site.
Example UDF:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cffunction name="getDateTime">
<cfreturn now() />
</cffunction>
1<cffunction name="getDateTime">
2 <cfreturn now() />
3</cffunction>
2)Then in my controller (in the onRequestStart):
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--- Add a UDF --->
<cfset variables.udf = createObject("component","pathTo.udf").init()>
<cfset arguments.event.setValue("udf", variables.udf)>
1<!--- Add a UDF --->
2<cfset variables.udf = createObject("component","pathTo.udf").init()>
3<cfset arguments.event.setValue("udf", variables.udf)>
3)On my view page I have
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--- Get UDF --->
<cfset udf = viewState.getValue('udf') />
1<!--- Get UDF --->
2<cfset udf = viewState.getValue('udf') />
Then to call a function
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cfoutput>#udf.getDateTime()#</cfoutput>
1<cfoutput>#udf.getDateTime()#</cfoutput>