Hi I have a CFC/component by name "tsks_Session", that performs the session tasks. In this cfc/ init () function, created a structure that contains all the variables needed in the application.Some of the variables are array types.
<cfcomponent >
<cffunction name="init">
<cfargument name="structKey" >
<cflock timeout="35" >
<cfset SESSION = structNew() >
<cfset SESSION.bar_code = "" >
<cfset SESSION.price = "" >
<cfset SESSION.pub_date = "01/01/1900" >
<cfset SESSION.author = ArrayNew() >
<cfset SESSION.title = ArrayNew() >
<cfset SESSION.[bar_code_subj_pric] = structNew() > <!--- key = concatanation of
bar_code and price --->
<cfset SESSION.[bar_code_subj_pric].author = ArrayNew() >
<cfset SESSION.[bar_code_subj_pric].title = ArrayNew() >
</cflock>
</cffunction>
<!---getter--->
<cffunction name="getAuthor" returntype="array" access="public" output="false">
<cfscript>return SESSION.author; </cfscript>
</cffunction>
<!---setter:adding the Array/"author" to the structue/"SESSION.[bar_code_subj_pric]" --->
<cffunction name="setAuthor" retuntype="void" access="public" output="false">
<cfargument name="bar_code_subj_pric" type="string" required="true">
<cfargument name="author" type="array" required="true">
<cfset var q = "" >
<cfparam name="author" default="" >
<cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].author)">
<cfset SESSION.author = ArrayAppend(SESSION.[bar_code_subj_pric].author,"#arguments.author#")>
</cfloop>
</cffunction>
<!---getter.title--->
<cffunction name="gettitle" returntype="array" access="public" output="false">
<cfscript>return SESSION.title; </cfscript>
</cffunction>
<!---setter:adding the Array/"title" to the structue/"SESSION.[bar_code_subj_pric]" --->
<cffunction name="settitle" retuntype="void" access="public" output="false">
<cfargument name="bar_code_subj_pric" type="string" required="true">
<cfargument name="title" type="array" required="true">
<cfset var q = "" >
<cfparam name="title" default="" >
<cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].title)">
<cfset SESSION.title = ArrayAppend(SESSION.[bar_code_subj_pric].title,"#arguments.title#")>
</cfloop>
</cffunction>
</cfcomponent>
1) on an display page, having instanitiated the cfc, i created a str called
<cfset str[expld133] =structnew()>
when i output the functions setAuthor("expld133",Kelly)/setTitle("expld133",33.22), i get "The value that i am not passing an array type".
Kindly tell me whats wrong?
2) can i create an structure called simply "SESSION" is it safe?
3)is there error in the way i am adding 2 different arrays(Author/Title) to the main structure "SESSION.[bar_code_subj_pric]"?
Please help Thanks