> So I changed all of my instance variables inside my component to the
> variables scope.  After I did this everything seemed to work fine until
> I tried to reference my member object.  I'm calling the object with
> invoke in my FB4.1 circuit file like:
>
> <invoke class="member" methodcall="get(url.memberid)"
> returnVariable="member" />

Just a suggestion, you might want to rename your returnVariable something
other than your class,
such as myMember or theMember, just to keep it readable.

>
> I used to reference my object on my dsp pages like member.fname and
> member.lname (when I was using the instance scope) but now that doesn't
> work anymore.  I get fname is undefined in member.

As Sean said this is exactly how its supposed to work.  Let say for
example, later in your application you start tracking name suffix's
(JR,SR,etc) and you want to keep then distinct (say in the database ) but
want to include them when displaying a last name. If your previous code had
<cfoutput>#myMember.getName()#</cfoutput>

<cffunction name="getName">
      <cfreturn fname & lname />
</cffunction>

You need only change one line of code, <cfreturn fname & lname & suffix />

Your application doesn't have to know anything about the new change.  This
probably isn't the best example why, but let me give you a better one.
Lets say you store their age in the database and you want to show certain
material to people over 18.  Under your old method, you might do the
following in your fuse,

<cfif myMember.age gte 18> show some pictures </cfif>

What happens when you no longer keep a members age but decide to start
keeping their birthdate, you'll have to go change all your display code.  A
better approach would be

<cfif myMember.isLegal() > show some picture </cfif>

Then let the member decide whether or not its legal with a function like
this
<cffunction name="isLegal">
      <cfif age gte 18>
            <cfreturn true />
      <cfelse>
            <cfreturn false />
      </cfif>
</cffunction>


When we start keeping by birthdate we change this to
<cffunction name="isLegal">
      <cfif datediff('y',now(),dob) gte 18 >
            <cfreturn true />
      <cfelse>
            <cfreturn false />
      </cfif>
</cffunction>
and we don't have to reformulate it throughout our site.  Or even better,
what if it depends on where they live

<cffunction name="isLegal">
      <cfif datediff('y',now(),variables.dob) gte 18 and
listfindNoCase("FL,GA,MA,MO",variables.state)>
            <cfreturn true />
      <cfelseif datediff('y',now(),variables.dob) gte 21>
            <cfreturn true />
      <cfelse>
            <cfreturn false />
      </cfif>
</cffunction>



Again, let the member Object decide its name, age, etc through get methods.

Jason Cronk
[EMAIL PROTECTED]



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:12:6744
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/12
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:12
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.12
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to