CFLib.org – Common Function Library Project

requestINOut([orderList])

Last updated September 2, 2005

author

Joseph Flanigan

Version: 2 | Requires: CF5 | Library: UtilityLib

Description:
Normalize input structures (URL, FORM, FLASH) to a single Request.IN structure for ubiquitous name space programming. The function prevents name space conflicts with input variable names by defining a normalization rank priority list. The default priority list rank (URL,FORM,FLASH) for name space assignment, can be re-prioritized by changing the parameter list order. Also, a struct called request.out is created.

Return Values:
Returns true on successful normalization.

Example:

<cfparam name="FORM.NAME" default="Jack">
<cfparam name="FORM.CITY" default="Loveland"> 
<cfparam name="URL.NAME" default="Jill"> 
<cfparam name="URL.STATE" default="CO">
<cfparam name="FORM.FIELDNAMES" default="Name,CITY">

<cfscript>
isNormalised = RequestINOut("FORM,URL");
</cfscript>

<cfif isNormalised>
 <cfoutput>
<br> #Request.IN.NAME# is Jill
<br> #Request.IN.CITY# is Loveland
<br> #Request.IN.STATE# is CO
<br> #Request.IN.FIELDNAMES# is NAME,STATE,CITY
</cfoutput> 
</cfif>

Parameters:

Name Description Required
orderList Order of scopes to normalize. Defaults to url, form, flash. No

Full UDF Source:

/**
 * Normalize input structures (URL, FORM, FLASH) to a single Request.IN structure for ubiquitous name space programming.
 * V2 for BlueDragon Support
 * 
 * @param orderList 	 Order of scopes to normalize. Defaults to url, form, flash. (Optional)
 * @return Returns true on successful normalization. 
 * @author Joseph Flanigan (joseph@switch-box.org) 
 * @version 2, September 2, 2005 
 */
function requestInOut() {
                var orderList = "url,form,flash";
                var i = 0;

                // if request.IN does not exist, create it
                if(not isDefined("request.IN")) {request.IN = structNew();}
                if(not isDefined("request.OUT")) {request.OUT = structNew();}

                if(arrayLen(arguments) gte 1) orderList = arguments[1];

                for (i=1;i lte listLen(orderList); i = i+1){
                        switch( UCase(listGetAt(orderList,i))) {
                                case "URL": {
                                        structAppend(request.IN,URL); // add URL
                                        break;
                                }

                                case "FORM": {
                                        structAppend(request.IN,FORM); // add FORM
                                        break;
                                }

                                case "FLASH": {
                                        if (IsDefined("FLASH")) structAppend(Request.IN,FLASH); // add FLASH
                                        break;
                                }
                        } //end switch
                } // end for

                if(not structIsEmpty(request.IN)) {
                        request.IN.FIELDNAMES = ""; // make sure fieldnames exist and is empty
                        request.IN.FIELDNAMES = structKeyList(request.IN); // make list of fieldnames
                        // then remove FIELDNAMES itself as a fieldname
                        request.IN.FIELDNAMES = listDeleteAt(request.IN.FIELDNAMES, listFindNoCase(request.IN.FIELDNAMES,"FIELDNAMES"));
                        return TRUE; // function end, input normalized
                }
                else return FALSE; // function end, nothing to normalize

}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson