Salut J'ai un CFC/composant nommé "tsks_Session", qui effectue les tâches de la session. Dans cette fonction cfc/init(), a créé une structure qui contient toutes les variables nécessaires dans l'application. Certaines des variables sont des types de tableau.Variables SESSION dans la structure 'avec' type '' Array '
<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) sur une page d'affichage, ayant instanitiated la cfc, i a créé une str appelé
<cfset str[expld133] =structnew()>
lorsque i sortie les fonctions SetAuthor ("expld133", Kelly)/setTitle ("expld133 ", 33,22), je reçois "The value that i am not passing an array type".
Veuillez me dire ce qui est faux? 2) puis-je créer une structure appelée simplement "SESSION" est-elle sûre?
3) Y a-t-il une erreur dans la façon dont j'ajoute 2 tableaux différents (Auteur/Titre) à la structure principale "SESSION. [Bar_code_subj_pric]"?