Do you have any examples of this? I think my first problem was stuffing all of the logic in one template, i have since seperated the logic into multiple templates and makes it easier for me (and more importantly other developers) to follow.
On 8/17/06, Kevin Roche <[EMAIL PROTECTED]> wrote:
Dan,In the past I have created a kind of framework for this type of thing. The framework is not very different from what you are doing but perhaps make it all a bit more readable.Basicly I would set up a list of fields for each page and loop over the list a few times.I am wondering if you can get the information to drive the framework from Reactor Metadata cfc.Kevin-----Original Message-----I would like to get everyone opinions on this subject. First off thanks to those who helped me with this issue earlier. Even though my problem is fixed and working I would like to find out what everyone else would do. I have a multiple step form submission, you could even think of it as a checkout process although its not. I am using reactor and here is a basic concept of what im doing
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Dan Vega
Sent: 16 August 2006 21:50
To: reactor; [email protected]
Subject: [Reactor for CF] best practices for multiple page form submission
** load my reactor records into session vars
<cfparam name="url.step" default="1">
<cfparam name="url.clientId" default="0">
<cfif NOT structKeyExists(session,"client")>
<cfset session.client.customer = application.reactor.createRecord("client").load(clientId=url.clientId)>
<cfset session.client.address = application.reactor.createRecord("address").load(userId= session.client.customer.getUserId())>
<cfset session.client.creditcard = application.reactor.createRecord("CreditCard").load(userId=session.client.customer.getUserId())>
<cfset session.client.user = application.reactor.createRecord("users").load(userId=session.client.customer.getUserId())>
<cfset session.client.advisor = application.reactor.createRecord("advisor").load(advisorId=session.client.customer.getAdvisorId ())>
</cfif>
*** if the form is submitted validate the data and set the variables into session scope
<cfif structKeyExists(form,"next.x")>
<cfif form.step EQ "1">
<cfset session.client.user.setUserId(form.userid)>
<cfset session.client.user.setUsername(trim(form.username))>
<cfset session.client.user.setEmailAddress(trim(form.emailaddress ))>
<cfset session.client.user.setEmailAddress2(form.emailaddress2)>
<cfset session.client.user.setPassword(form.password)>
<cfset session.client.user.setPassword2(form.password2 )>
<cfset session.client.user.validate() />
<cfset errorCollection = session.client.user._getErrorCollection() />
<cfif NOT errorCollection.hasErrors()>
<cfset url.step = 2 >
</cfif>
<cfelseif form.step EQ "2">
<cfset session.client.customer..setAdvisorId(form.advisor)>
<cfset session.client.customer.setMarital (form.marital)>
<cfset session.client.customer.setResidence(form.residence)>
<cfset session.client.customer.setSat(form.sat)>
<cfset session.client.customer.setAct(form.act )>
<cfset session.client.customer.setMethod(form.method)>
<cfset session.client.customer.setStatus(form.status)>
<cfset session.client.customer.validate() />
<cfset errorCollection = session.client.customer._getErrorCollection()>
<cfif NOT errorCollection.hasErrors()>
<cfset url.step = 3>
</cfif>
</cfif>
**** collect data in a form based on the step
<cfif url.step eq "1">
<fieldset>
<legend>User Details</legend>
<input type="hidden" name="step" value="#url.step#">
<p>
<label for=""><input type="text" name="username" id="username" value="#session.client.user.getUsername()#">
</p>
<p>
<label for="" Address:</label>
<input type="text" name="emailaddress" id="emailaddress" value="#session.client.user.getEmailAddress()#">
</p>
<p>
<label for="" Email:</label>
<input type="text" name="emailaddress2" id="emailaddress2" value="#session.client.user.getEmailAddress()#">
</p>
<p>
<label for=""><input type="password" name="password" id="password" value="#session.client.user.getPassword()#">
</p>
<p>
<label for="" Password:</label>
<input type="password" name="password2" id="password2" value="#session.client.user.getPassword2()#">
</p>
<p>
<input type="image" name="next" id="next" src="" alt="Proceed to the Next Step" width="77" height="30" border="0" align="right"
</p>
</fieldset>
</cfif>
**** finally after all data has been collected and validated, save all of the data in a transaction (now shown yet)
<cfif url.step eq "6">
<cfset session.client.user.save(false)>
<!--- client; needs userId --->
<cfset session.client.customer.setUserId(session.client.user.getUserId ())>
<cfset session.client.customer.save(false)>
<!--- address --->
<cfset session.client.address.setUserId(session.client.user.getUserId())>
<cfset session.client.address.save(false)>
<!--- creditcard --->
<cfset session.client.creditcard.setUserId(session.client.user.getUserId())>
<cfset session.client.creditcard.save(false)>
<!--- user groups --->
<cfset ugRecord = application.reactor.createRecord("users_groups")>
<cfset ugRecord.setUserId(session.client.user.getUserId())>
<!--- 4 is client --->
<cfset ugRecord.setGroupId(4)>
<cfset ugRecord.save()>
<cfset structClear( session.client)>
</cfif>
I would just like to know if there is a better way of doing this, again it works but it just doesnt seem clean at all to me and I would like a better way of doing it. I have 500 lines of code that looks unmaintainable to anyone else!
Thanks for everyones time
--
Dan Vega
[EMAIL PROTECTED]
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
Dan Vega
[EMAIL PROTECTED]
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
