I'm not sure I understand what you are asking.

If you return "THIS" you can simply string the init() method on your
createObject call.

So, something like:

user = createObject("...").init("Nathan","Dintenfass");

userName = user.getName();

I don't understand what you mean by "variables.user.firstName" -- though, if
you mean to directly access the "firstName" data member of "User" that is
exactly what you shouldn't do -- keep your instance data inside your CFC and
build the appropriate API using methods to get the data out in a way that
makes sense for your component.

See the list archive for fuller discussions of why "public" data is bad.


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Joe Eugene
> Sent: Tuesday, October 07, 2003 1:26 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [CFCDev] Variable referencing in CFCs
>
>
> > I also always return THIS from the init() method to allow me to do:
> > foo = createobject("component","foo").init();
>
> If you return THIS from the init() method, you only get reference to
> Instance methods.
> No Instance variables are returned.
>
> >From the below example..
> user = createObject("Component", "User");
>
> This will fail, if you return THIS Instead of Variables.
> <cfoutput>#variables.user.firstName#</cfoutput>
>
> Are you using "This", so you can declare Accessor Methods to get Instance
> Variables?
>
>
> Joe Eugene
>
>
>
> ----- Original Message -----
> From: "Nathan Dintenfass" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, October 07, 2003 11:46 AM
> Subject: RE: [CFCDev] Variable referencing in CFCs
>
>
> > Yes, though I set up the variables in the init() method instead of the
> > pseudo-constructor area.
> >
> > I also usually don't put variables. in front of instance once
> I've created
> > it.
> >
> > I also always return THIS from the init() method to allow me to do:
> >
> > foo = createobject("component","foo").init();
> >
> > But, you've got the idea.
> >
> >
> > >
> > > So essentially, are u saying the below is the apt usage?
> > > <cfcomponent>
> > >  <cfset variables.instance = structNew() />
> > >  <cfset variables.instance.firstName = "" />
> > >  <cfset variables.instance.lastName = "" />
> > > <cfFunction name="init" access="public" returntype="struct"
> > > output="false">
> > >   <cfset variables.instance.firstName = "Bob" />
> > >   <cfset variables.instance.lastName = "Smith" />
> > >  <cfReturn variables.instance />
> > > </cfFunction>
> > > </cfcomponent>
> > >
> > > Joe
> > >
> >
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email
> > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> > in the message of the email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > by Mindtool, Corporation (www.mindtool.com).
> >
> > An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to