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
-~----------~----~----~----~------~----~------~--~---

Attachment: Application.cfc
Description: application/cfc

Reply via email to