[cfaussie] Re: Application object
onApplication will only start / excute when there is no application named with this.name. You may need to put a ?uppdateapp=1 in your url to reset the application in onRequestStart. cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. http://www.aegeon.com.au www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
had the application already been run before you added the create object? If so, you will need to restart the application (or bounce the CF service) so the OnApplicationStart function gets executed On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Yes. So I have to put the object in onRequestStart or top of the page to init? On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: had the application already been run before you added the create object? If so, you will need to restart the application (or bounce the CF service) so the OnApplicationStart function gets executed On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, George Lu [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
I think its because you have variables.componentPath in the string to go find it. On application start this wont exist. Personally I would set this up as an application variable, then after that set up the object. On 6/7/07, George Lu [EMAIL PROTECTED] wrote: No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, George Lu [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- Duncan I Loxton [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Yes, Andrew's method of restarting the application is a good one. Beats restarting CF. Mind you be careful as to what url you need to pass the application to cause a restart, obviously if this got in the wrong hands. You can have a totally separate page if you wish, that takes some type of password. http://www.site.com/appRestart.cfm This could ask for a password and restart the app by calling the Application methods Andrew used. This way the method of restarting your app doesn't end up in browser caches etc, at least not the password bit. Regards Dale Fraser http://dalefraser.blogspot.com http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:51 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Did you pass the url http://site.com/pageName.cfm?updateapp=true Regards Dale Fraser http://dalefraser.blogspot.com http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:57 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, George Lu [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Yes, I did (myPage.cfm?updateapp=1). The page shows up then it stop work when I pass myPage.cfm?userID=15. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Did you pass the url http://site.com/pageName.cfm?updateapp=true Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:57 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, George Lu [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
As Dale said, this can have undesired results if used in the wrong situation. However in my case, and not everyone is the same in this regard. But I only use that method on my development server, and prefer to have a temp file that is deleted when it is executed to restart the application when changes have been made to the Application.cfc which is very rare for my current clients work. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dale Fraser Sent: Thursday, 7 June 2007 1:01 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object Yes, Andrew's method of restarting the application is a good one. Beats restarting CF. Mind you be careful as to what url you need to pass the application to cause a restart, obviously if this got in the wrong hands. You can have a totally separate page if you wish, that takes some type of password. http://www.site.com/appRestart.cfm This could ask for a password and restart the app by calling the Application methods Andrew used. This way the method of restarting your app doesn't end up in browser caches etc, at least not the password bit. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:51 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:32 PM To: CFAussie Mailing List Subject: [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~--- Application.cfc Description: application/cfc
[cfaussie] Re: Application object
Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath / cfset request.surveyGateway = Application.surveyGateway / cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath/ cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [ Ljava.lang.String; referenced
[cfaussie] Re: Application object
no, because if the APPLICATION scope does not exist OnApplicationStart () will be fired On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath / cfset request.surveyGateway = Application.surveyGateway / cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init( variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath/ cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List
[cfaussie] Re: Application object
But I've been told if I change the object in cfc I have to init the object again in myPage.cfm so the change'll happen. Is that true? On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: no, because if the APPLICATION scope does not exist OnApplicationStart () will be fired On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath / cfset request.surveyGateway = Application.surveyGateway/ cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init( variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump
[cfaussie] Re: Application object
George, The answer is yes, but in your case it is no. The reason being is that if you are using DataMgr.cfc and have made changes then yes, this has to reinitialised for the changes to take effect. So in your case http://mydomain/?updateapp=true when you have made changes will solve that problem for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 2:34 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object But I've been told if I change the object in cfc I have to init the object again in myPage.cfm so the change'll happen. Is that true? On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: no, because if the APPLICATION scope does not exist OnApplicationStart () will be fired On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath / cfset request.surveyGateway = Application.surveyGateway / cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of George Lu Sent: Thursday, 7 June 2007 12:57 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, George Lu [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, Dale Fraser [EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application
[cfaussie] Re: Application object
any code inside the OnApplicationStart function will only run the first time the application is run. So if you put in a new CreateObject() you will need will need to do the ?updateapp=1 If you change a CFC that has already been created and stored in the APPLICATION scope, you will also need to do updateapp=1 as the old version will still be there. On 6/7/07, George Lu [EMAIL PROTECTED] wrote: But I've been told if I change the object in cfc I have to init the object again in myPage.cfm so the change'll happen. Is that true? On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: no, because if the APPLICATION scope does not exist OnApplicationStart () will be fired On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath/ cfset request.surveyGateway = Application.surveyGateway/ cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component, variables.componentPath .components.surveyDAO).init( variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO/ cfset request.dsn = variables.dsn
[cfaussie] Re: Application object
Thanks Andrew and AJ. Now I understand - once an object is initialised in OnApplicationStart function then it's available in every page. If the object is changed or a new object is created after app start then we need to reinitialise/initialise it using something like http://mysite/?updateapp=true. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: any code inside the OnApplicationStart function will only run the first time the application is run. So if you put in a new CreateObject() you will need will need to do the ?updateapp=1 If you change a CFC that has already been created and stored in the APPLICATION scope, you will also need to do updateapp=1 as the old version will still be there. On 6/7/07, George Lu [EMAIL PROTECTED] wrote: But I've been told if I change the object in cfc I have to init the object again in myPage.cfm so the change'll happen. Is that true? On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: no, because if the APPLICATION scope does not exist OnApplicationStart () will be fired On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Thanks AJ. But for the objects, do I need to do something like this on myPage.cfm? cfif NOT isDefined(Application.surveyDAO) cfset Application.surveyDAO = createObject(component, intranet.hr.survey.components.surveyDAO).init(HR) / /cfif in the event the object is not initialised. On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: As per A.S. loose (delete/remove/cut/destroy) these lines in onRequestStart cfset request.componentPath = variables.componentPath/ cfset request.surveyGateway = Application.surveyGateway / cfset request.surveyDAO = Application.surveyDAO / move these to OnApplicationStart cfset request.dsn = variables.dsn / cfset application.root = /Intranet / and change request to application for the dsn cfset APPLICATION.dsn = variables.dsn / Then in you code, reference Application.surveyDAO1 Application.hrSurveyObj APPLICATION.dsn So what you end up with is all the APPLICATION wide variables are defined as set in OnApplicationStart(). No need to copy them into the REQUEST scope On 6/7/07, George Lu [EMAIL PROTECTED] wrote: Hi AJ, That's what I did in application.cfc (see attached file as requested by Andrew). On 07/06/07, AJ Mercer [EMAIL PROTECTED] wrote: Hi George, I think you are after something more like this: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfreturn true /cffunction If the URL.updateapp exists - it will call onApplicationStart which will initialise your object for you. Then you can use Application.surveyDAO anywhere in you application On 6/7/07, Andrew Scott [EMAIL PROTECTED] wrote: Looks like Peter got to youJ If you set the Object up in onApplicationStart, there is no need and I mean this!! No need to copy the Application.surveyDAO to the request scope. I would really like to know who is teaching people to do this, can you imagine 1000 users hitting the application and how many extra ram is wasted by such a method.. Peter might like doing this and wasting valuable resources, but it should not be a practice taken upon. If you want to email me your application.cfc, I will modify it and get it to work for you. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType
[cfaussie] Re: Application object
*From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
*ROTFLMAO* The funniest thing I have heard this week... Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of AJ Mercer Sent: Thursday, 7 June 2007 3:15 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Application object you can loosen you seatbelt now, the ride wont be so bumpy. But the captain asks that you refrain from using the REQUEST scope in case there is any further turbulence. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Application object
. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:57 PM *To:* cfaussie@googlegroups.com *Subject:* [cfaussie] Re: Application object No, I've tried Andrew's method: cffunction name=onRequestStart returnType=boolean cfargument type=String name=targetPage required=true / cfif isDefined(url.updateapp) cfset result = onApplicationEnd() / cfset result = onApplicationStart() / /cfif cfset request.componentPath = variables.componentPath / cfset request.surveyDAO = Application.surveyDAO / cfset request.dsn = variables.dsn / cfreturn true /cffunction and the same error again. On 07/06/07, *George Lu* [EMAIL PROTECTED] wrote: Dale, I put the application scope on top of the page then it works. Maybe I should do it as Andrew suggested. Thanks everyone. On 07/06/07, *Dale Fraser *[EMAIL PROTECTED] wrote: Are you sure it got created. Possibly added the OnApplicationStart code after the app was already started. Dump the Application scope and see of the surveyDAO exists in it. Regards Dale Fraser http://dalefraser.blogspot.com *From:* cfaussie@googlegroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *George Lu *Sent:* Thursday, 7 June 2007 12:32 PM *To:* CFAussie Mailing List *Subject:* [cfaussie] Application object Hi, I create an object in Application.cfc and put it in the application scope. When I use it in other pages it comes up this error: Element SURVEYDAO is undefined in a Java object of type class [Ljava.lang.String; referenced as The object in application.cfc: cffunction name=OnApplicationStart cfset Application.surveyDAO = createObject(component,variables.componentPath .components.surveyDAO).init(variables.dsn) / cfset Application.hrSurveyObj = CreateObject(component, CFC.DataMgr).init(HR,MSSQL) / /cffunction The code causing the error: cfset Application.surveyDAO.delete(url.userID) / Please help! George -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. -- If you are not living on the edge, You are taking up too much space. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---