The wddxFormLibrary Library w/CF_FormWizard
The wddxFormLibrary will also handle repopulating the form from an existing WDDX packet (created with the wddxFormLibrary function calls.) This means you can easily take snapshots of a form's content and repopulate the page without any additional server-side coding.
Because of the unique nature in which the wddxFormLibrary works, you can do a number of things very quickly, easily and most important efficiently. In a nutshell, wddxFormLibrary takes a virtual "snapshot" of the way the current form is laid out. This means that you can use it on existing forms, store the WDDX packet in the database and any time someone needs to re-edit that information, simply grab the packet back from the database and pass it back to the form. Once the user's browser loads the page, the form will automatically be returned to the way the user last left it.
The wddxFormLibrary also simplifies your server-based coding. How many times have you created a multi-part form where you have to first check for existing information, code the page, check to see if the form fields should be populated with saved information; then after the page has been submitted, you have to write all the information back to the database? This is a very time consuming processnot only in terms of coding, but in terms of the CPU processing. With wddxFormLibrary this method is a thing of the past. All you need to do is point each form's "ACTION" attribute to the next page you want data collected from, then once all the information is collected, you can store all of the information in just one step. (Note, for added precaution you could store the WDDX packet between each page and check the database just for that packet. This would protect users from losing information if their machine crashed or they close their browser on accident.)
To see the wddxFormLibrary in action, check out the examples below:
|Shows how wddxFormLibrary can be used on a single page to take a snapshot of the content, or how it can be used to collect the same information multiple times.|
|Shows how wddxFormLibrary can be used on a multi-part form. Uses <CF_FormWizardTools ACTION="Flatten"> to convert the final packet into an easier to use format.|
|Shows how you can use the changeForm() and getPacketArray() functions to build custom forms that allow you to edit multiple records without reloading.|
|Shows you how to use the <CF_FormWizardTools ACTION="Create"> function to create default values for your forms by building a simple structure. (NOTE: The source code also includes an example of how you could retrieve a stored packet as well.)|
The CREATE action will allow you to quickly create default values for single page forms or forms where you'll be editing the same data on every page. (Remember, you can also manually create a default packet by simply create a correct formatted structure and serializing it to WDDX.)
The required values for this attribute are: ACTION, INPUT. The INPUT field requires an fully evaluate structure or query object. The attributes KEY, TITLE and URL are option and vary in function depending on whether you're passing a structure or query object.
When passing a structure object, you'll want to pass the string values to each optional attribute that you want appear in the WDDX packet. By default, the KEY and URL attribute will return the URL of the calling template and TITLE attribute will be blank.
If passing a query object, you'll want to pass the column name that each optional attribute should use to retrieve it's value from. By default the value from each attribute will be gathered from the first column return by the CF's ColumnList variable. (NOTE: If you'd like prefix you're URL keys with a default string, use the option DefaultURL attribute. This is useful if you're using a primary/foreign key column for the value and would like to have the value prefixed with the page's URL. (i.e. DefaultURL="index.cfm?id=" would added the string "index.cfm?id=" before each URL key in the structure.)
The "Serialize" action will convert the WDDX packet into a valid ColdFusion structure. To specify the output name, use the OUTPUT attribute. (Default is "stcFormWizard".)
The "Flatten" action will flatten the structure into a structure only one level deep. This is great for using the library in a true wizard-like style. (See "Example 2.")