Hi
I tried your code and it worked perfectly (assuming that I
called it correctly(?)).
<cfset genser = createObject("component",
"genser").init()>
<cfset temp =
genser.getFarge()>
#temp#<br/>
#temp#<br/>
<cfset genser.setFarge("t_hvit")>
<cfset temp =
genser.getFarge()>
#temp#<br/>
#temp#<br/>
The output:
Yellow
White
I'm
running CF 7.01 on WinXP.
Perhaps the problem lies in some other code?
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Waterswing Studio Trond Ulseth
Sent: Friday, 5 May 2006 10:50 AM
To: [email protected]
Subject: [CFCDev] Strange cfc problem
I got a cfc bean that models a sweater.
One of it's attributes is color.
The argument for color passed in is something like "t_gul".
I want to "translate" the color to normal language.
When I try the following (pseudo) code I get an error:
Element is undefined in a CFML structure referenced as part of an _expression_.
Tag Context D:\Inetpub\kunder\nordicprint\model\beans\genser.cfc
(I've made bold the line throwing the error)
Can someone explain why this does not work?
genser.cfc:
<cfcomponent
displayname="genser"
output="false"
hint="A bean which models the genser form.">
<!---
PROPERTIES
--->
<cfset variables.instance = StructNew() />
<!--- "translate" colors --->
<cfset variables.colors = StructNew() />
<cfset variables.colors["t_gul"] = "Yellow" />
<cfset variables.colors["t_hvit"] = "White" />
<!---
INITIALIZATION / CONFIGURATION
--->
<cffunction name="init" access="public" returntype="genser" output="false">
<cfargument name="objectid" type="uuid" required="false" default="#createUUID()#" />
<cfargument name="farge" type="string" required="false" default="t_gul" />
<cfscript>
// run setters
setObjectid( arguments.objectid);
setFarge(arguments.farge);
</cfscript>
<cfreturn this />
</cffunction>
<!---
ACCESSORS
--->
<cffunction name="setObjectid" access="public" returntype="void" output="false">
<cfargument name="objectid" type="uuid" required="true" />
<cfset variables.instance.objectid = arguments.objectid />
</cffunction>
<cffunction name="getObjectid" access="public" returntype="uuid" output="false">
<cfreturn variables.instance.objectid />
</cffunction>
<cffunction name="setFarge" access="public" returntype="void" output="false">
<cfargument name="farge" type="string" required="true" />
<cfset variables.instance.farge = variables.colors[arguments.farge] />
</cffunction>
<cffunction name="getFarge" access="public" returntype="string" output="false">
<cfreturn variables.instance.farge />
</cffunction>
</cfcomponent>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
This email and any attachments to it are confidential. You must not use, disclose or act on the email if you are not the intended recipient. Liability limited by a scheme approved under Professional Standards Legislation. Deloitte is a member of Deloitte Touche Tohmatsu (a Swiss Verein). As a Swiss Verein (association), neither Deloitte Touche Tohmatsu nor any of its member firms has any liability for each other's acts or omissions. Each of the member firms is a separate and independent legal entity operating under the names "Deloitte", "Deloitte & Touche", "Deloitte Touche Tohmatsu", or other related names. Services are provided by the member firms or their subsidiaries and affiliates and not by the Deloitte Touche Tohmatsu Verein.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
