I had to take few bits out that were specific to my app. I hope it still
runs as it should.
You should probably name "contactNew" structure more specific to your app.

The structDelete(contactNew.form, "BTNSUBMIT"); stuff is just so I don't
save buttons in the structure

Its as simple as calling the following for the first time, i.e. you have not
created the session structure yet.

<!--- store form --->
<cfinvoke component="#application.setting["mapping"]#component/form"
method="fnStore">
<cfinvokeargument name="formField" value="#form#">
</cfinvoke>

And the following to append, i.e. every submit after the the above
<!--- append form --->
<cfinvoke component="#application.setting["mapping"]#component/form"
method="fnAppend">
<cfinvokeargument name="formField" value="#form#">
</cfinvoke>

Should you want to copy everything back to the FORM scope you run the
following
<!--- reinitialize form --->
<cfinvoke component="#application.setting["mapping"]#component/form"
method="fnReinitialize" returnvariable="form">
<cfinvokeargument name="formContainer"
value="#session.contactNew.form#">
</cfinvoke>

The CFC

<!---
############################################################################
##########
##
## author: Taco Fleur ([EMAIL PROTECTED])
## description: component that works with the form object
##
############################################################################
##########
--->
<cfcomponent displayname="Form" hint="component that works with the form
object">

<!---

############################################################################
##########
##
## function: reinitialize form values, i.e. copy form values back to
the local scope
##

############################################################################
##########
--->
<cffunction access="public"
name="fnReinitialize"
output="false"
returntype="struct"
displayname="Reinitialize"
hint="reinitialize form values, i.e. copy form
values back to the local scope">

<cfargument name="formContainer" type="struct"
required="true">

<cfset form = structNew()>
<!--- copy structure to local scope --->
<cflock timeout="10" throwontimeout="no" type="readonly"
scope="session">
<cfset form = duplicate(arguments.formContainer)>
</cflock>

<cfreturn form>
</cffunction>

<!---

############################################################################
##########
##
## function: store form values in session scope
##

############################################################################
##########
--->
<cffunction access="public"
name="fnStore"
output="false"
displayname="Store"
hint="store form values in session scope">

<cfargument name="formField" type="struct" required="true">

<!--- create structure to store form fields --->
<cfscript>
contactNew = structNew();
structInsert(contactNew, "form", arguments.formField);
// delete any button data from the structure
structDelete(contactNew.form, "BTNSUBMIT");
</cfscript>
<cftry>
<!--- copy structure to session scope --->
<cflock timeout="10" throwontimeout="no"
type="exclusive" scope="session">
<cfset session.contactNew =
duplicate(contactNew)>
</cflock>
<cfcatch>
<!--- error --->
</cfcatch>
</cftry>

</cffunction>

<!---

############################################################################
##########
##
## function: append form values to form in session scope
##

############################################################################
##########
--->
<cffunction access="public"
name="fnAppend"
output="false"
displayname="Append"
hint="append form values to form in session scope">

<cfargument name="formField" type="struct" required="true">

<cftry>
<cflock timeout="10" throwontimeout="no"
type="exclusive" scope="session">
<!--- append form fields to existing
structure --->
<cfscript>
structAppend(session.contactNew.form,
arguments.formField, "true");
// delete any button data from the structure
structDelete(session.contactNew.form,
"BTNSUBMIT");
</cfscript>
</cflock>
<cfcatch>
<!--- error --->
</cfcatch>
</cftry>

</cffunction>

</cfcomponent>

Hope it helps
PS. Any comments, new ideas, improvements welcome

Taco Fleur
Blog http://www.tacofleur.com/index/blog/
Methodology http://www.tacofleur.com/index/methodology/
0421 851 786
Tell me and I will forget
Show me and I will remember
Teach me and I will learn

> -----Original Message-----
> From: Bob Haroche [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 29 January 2004 6:34 PM
> To: Taco Fleur
> Subject: Re: How to Pass Varibles on Multipage Form?
>
>
> Hello Taco,
>
> > Work with the session scope, as soon as a page is submitted
> you append
> > the FORM structure to a structure stored in the session, I have a
> > CFC that does
> > the trick if your interested.
>
>
> I'd love to get a copy of that CFC if you don't mind. Thank you in
> advance.
>
>
> -------------
> Regards,
> Bob Haroche
> O n P o i n t  S o l u t i o n s
> www.OnPointSolutions.com
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to