Struct state between pages in an application

2002-10-07 Thread Yexley Robert D Contr Det 1 AFRL/WSI

OK, I've made this disclaimer before, but it still applies: I'm really new when it 
comes to CF, so I request that you please keep that in mind as you read this.  I don't 
claim that as an excuse for not searching out the answers on my own, but I've been 
unable to find an explanation of this behavior in the CF docs so far.  So anyway...

I've got this form, and I want to use the selected/input values from the form to call 
a stored procedure that is within a package in an Oracle database for processing.  
But, before passing the values to the database, I want the user to be able to confirm 
the selections that they've made before sending the information to the database.  So, 
at the beginning of the page that displays the form, I check to see if the structure 
is defined, and if it's not, I create it.  (I realize that what you're about to read 
may not make sense if it's not the best way to do this, but it was the only way that I 
could figure out to do it, so this is how it currently works...I'm open to 
suggestions)  So, on the form page, the action is GET, and on the action page, I first 
populate all of the properties of the structure with the URL parameters that have been 
passed from the form, by evaluating their values in the URL.  I then display the users 
selections, by outputting the values of the structure p!
roperties.  All of this to this point works fine.  The fact that it works fine, 
suggests to me that structures reside in memory on the CF server, and can persist 
between templates in an application.  So, based on that assumption, I also assumed 
that the properties of the structure would be available on the NEXT page as well.  The 
action page for the form, has two links at the bottom of it, after all of the values 
that the user has selected are displayed for confirmation...one link is a back button, 
that allows the user to go back to the form and make any necessary corrections to 
their input, and the other is a link to another template that actually process the 
form by passing all of the properties of the structure to the stored procedure in the 
database for processing.  The first thing I do in this template, is check for the 
existence of the structure, to make sure that it's values can be passed to the stored 
procedure.  This is where my problem comes up.  Every time I click!
 the link to go to this template for processing, I get the me!
ssage that gets displayed if the structure does not exist (it's a message that I've 
inserted to let the user know that there was an error, due to the fact that the 
structure cannot be found, and processing cannot continue).  What am I doing wrong?  
Why is the server not finding this structure?  Am I not defining it properly to be 
available across multiple templates or something like that?  Any thoughts would be 
greatly appreciated.  The code for checking for the existence of the structure is 
below.  Thanks in advance.

cfif not isDefined(myStructure)
pThe structure does not exist.  Blah blah blah./p
cfelse
...
/cfif

::YEX::
)))

/*
|| Robert D. Yexley
|| Oracle Programmer/Analyst
|| Northrop Grumman IT
|| Contractor - Wright Research Site MIS
|| Det-1 AFRL/WSI Bldg. 45 Rm. 062
|| (937) 255-1984
|| [EMAIL PROTECTED]
|| )))
*/


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



RE: Struct state between pages in an application

2002-10-07 Thread Everett, Al

Like any other variable in the local scope, the structure you're creating
ceases to exist when the page finishes processing. You'll need to put it in
a persistent scope (Session, Client) or in some other way pass it to the
next page (serialize it with WDDX and put it in a hidden form variable,
deserializing it on the next page; using Uncle Ben's CF_embedformfields tag;
etc.)

You'll probably want to use Session variables.

1. Remember your CFLOCKs
2. You should probably delete the structure in Session when you get to your
processing page so it's not hanging around.

 OK, I've made this disclaimer before, but it still applies: 
 I'm really new when it comes to CF, so I request that you 
 please keep that in mind as you read this.  I don't claim 
 that as an excuse for not searching out the answers on my 
 own, but I've been unable to find an explanation of this 
 behavior in the CF docs so far.  So anyway...
 
 I've got this form, and I want to use the selected/input 
 values from the form to call a stored procedure that is 
 within a package in an Oracle database for processing.  But, 
 before passing the values to the database, I want the user to 
 be able to confirm the selections that they've made before 
 sending the information to the database.  So, at the 
 beginning of the page that displays the form, I check to see 
 if the structure is defined, and if it's not, I create it.  
 (I realize that what you're about to read may not make sense 
 if it's not the best way to do this, but it was the only way 
 that I could figure out to do it, so this is how it currently 
 works...I'm open to suggestions)  So, on the form page, the 
 action is GET, and on the action page, I first populate all 
 of the properties of the structure with the URL parameters 
 that have been passed from the form, by evaluating their 
 values in the URL.  I then display the users selections, by 
 outputting the values of the structure p!
 roperties.  All of this to this point works fine.  The fact 
 that it works fine, suggests to me that structures reside in 
 memory on the CF server, and can persist between templates in 
 an application.  So, based on that assumption, I also assumed 
 that the properties of the structure would be available on 
 the NEXT page as well.  The action page for the form, has two 
 links at the bottom of it, after all of the values that the 
 user has selected are displayed for confirmation...one link 
 is a back button, that allows the user to go back to the form 
 and make any necessary corrections to their input, and the 
 other is a link to another template that actually process the 
 form by passing all of the properties of the structure to the 
 stored procedure in the database for processing.  The first 
 thing I do in this template, is check for the existence of 
 the structure, to make sure that it's values can be passed to 
 the stored procedure.  This is where my problem comes up.  
 Every time I click!
  the link to go to this template for processing, I get the me!
 ssage that gets displayed if the structure does not exist 
 (it's a message that I've inserted to let the user know that 
 there was an error, due to the fact that the structure cannot 
 be found, and processing cannot continue).  What am I doing 
 wrong?  Why is the server not finding this structure?  Am I 
 not defining it properly to be available across multiple 
 templates or something like that?  Any thoughts would be 
 greatly appreciated.  The code for checking for the existence 
 of the structure is below.  Thanks in advance.
 
 cfif not isDefined(myStructure)
   pThe structure does not exist.  Blah blah blah./p
 cfelse
   ...
 /cfif
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: Struct state between pages in an application

2002-10-07 Thread S . Isaac Dealey

I don't think you can store complex objects like structures in the client
scope without first serializing them into a wddx packet... ( which would be
similar to passing it in a form, just different management of the packet
)... however...

I think Al's right, sessions are probably your best bet...

I'd change the action in your form from GET to POST and put this on your
intermediary action page:

cfif isdefined(form.myrequiredfield)
cflock scope=session type=exclusive timeout=10
cfset session.mystruct = duplicate(form)
/cflock
cflocation url=#cgi.path_info# addtoken=nocfabort
cfelse
cflock scope=session type=readonly timeout=10
cfif structkeyexists(session,mystruct)
cfset mystruct = duplicate(session.mystruct)/cfif
/cflock
/cfif

cfif isdefined(mystruct)
... output the structure and the form to go to the next page here...
cfelse
... custom error message ...
/cfif

The reason for using POST instead of GET is to insulate the data from a
mangled or over-long url for whatever reason. If it sees your required form
field, it coppies the data into the request scope, then relocates to the
current page without the form, so that if the user refreshes the page, they
won't get the annoying do you want to repost the form message. It then
grabs the data from the session scope and if everything is okay, they can
hit the next button and on the following page, you can grab the data from
the request scope again, as in the else clause above.



hth

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

 Like any other variable in the local scope, the structure you're creating
 ceases to exist when the page finishes processing. You'll need to put it
 in
 a persistent scope (Session, Client) or in some other way pass it to the
 next page (serialize it with WDDX and put it in a hidden form variable,
 deserializing it on the next page; using Uncle Ben's CF_embedformfields
 tag;
 etc.)

 You'll probably want to use Session variables.

 1. Remember your CFLOCKs
 2. You should probably delete the structure in Session when you get to
 your
 processing page so it's not hanging around.

 OK, I've made this disclaimer before, but it still applies:
 I'm really new when it comes to CF, so I request that you
 please keep that in mind as you read this.  I don't claim
 that as an excuse for not searching out the answers on my
 own, but I've been unable to find an explanation of this
 behavior in the CF docs so far.  So anyway...

 I've got this form, and I want to use the selected/input
 values from the form to call a stored procedure that is
 within a package in an Oracle database for processing.  But,
 before passing the values to the database, I want the user to
 be able to confirm the selections that they've made before
 sending the information to the database.  So, at the
 beginning of the page that displays the form, I check to see
 if the structure is defined, and if it's not, I create it.
 (I realize that what you're about to read may not make sense
 if it's not the best way to do this, but it was the only way
 that I could figure out to do it, so this is how it currently
 works...I'm open to suggestions)  So, on the form page, the
 action is GET, and on the action page, I first populate all
 of the properties of the structure with the URL parameters
 that have been passed from the form, by evaluating their
 values in the URL.  I then display the users selections, by
 outputting the values of the structure p!
 roperties.  All of this to this point works fine.  The fact
 that it works fine, suggests to me that structures reside in
 memory on the CF server, and can persist between templates in
 an application.  So, based on that assumption, I also assumed
 that the properties of the structure would be available on
 the NEXT page as well.  The action page for the form, has two
 links at the bottom of it, after all of the values that the
 user has selected are displayed for confirmation...one link
 is a back button, that allows the user to go back to the form
 and make any necessary corrections to their input, and the
 other is a link to another template that actually process the
 form by passing all of the properties of the structure to the
 stored procedure in the database for processing.  The first
 thing I do in this template, is check for the existence of
 the structure, to make sure that it's values can be passed to
 the stored procedure.  This is where my problem comes up.
 Every time I click!
  the link to go to this template for processing, I get the me!
 ssage that gets displayed if the structure does not exist
 (it's a message that I've inserted to let the user know that
 there was an error, due to the fact that the structure cannot
 be found, and processing cannot continue).  What am I doing
 wrong?  Why is the server not finding this structure?  Am I
 not defining it properly to be