ColdBox Framework Forums Notification: Post to Request Context Decorator

Title: Request Context Decorator
Thread: Request Context Decorator
Forum: Discussions
Conference: ColdBox
User: danfusion I started playing around with the request context decorator today and I'm amazed
at how powerful this is. Originally, I was using a plugin to create a url dump
of the request collection that I needed to pass to the next page. I also had a
method to create Javascript args from the request collection to pass to the
ajaxproxy for an ajax call. I added both of these functions to the example that
Luis had in the Request Context Decorator guide, and ta-da! It works! It's
really neat to be able to now call Event.getRcAsUrl() instead of remembering
whether or not I have a plugin loaded.

[code]
<cfcomponent
name="rcDecorator" hint="This is a simple custom request context"
extends="coldbox.system.beans.requestContextDecorator" output="false">
<cffunction name="configure" access="public" returntype="void" hint="This is the
configuration method for your context as its created." output="false" >
<!--- n/a --->
  </cffunction>
  
  <cffunction name="getRcAsUrl"
returntype="string" access="Public" hint="This returns request collection in a
URL format" output="false">
    <cfset var rc =
getRequestContext().getCollection()>
    <cfset var rtnUrlString = "">

    <!---
remove unused portions of scope (i.e. fieldnames,event) --->
    <cfset
tempEventScope = Duplicate(rc)>
    <cfset
StructDelete(tempEventScope,"event",false)>
    <cfset
StructDelete(tempEventScope,"coldbox_debugpanel",false)>
    
    <cfloop
collection="#tempEventScope#" item="key">
      <cfset rtnUrlString = rtnUrlString
& "&" & key & "=" & URLEncodedFormat(tempEventScope[key])>
    </cfloop>
<cfreturn rtnUrlString />
  </cffunction>
  
  <cffunction name="getRcAsJsArgs"
access="public" output="false" hint="This returns request collection in a
Javascript Arguments format" returnType="string">
    <cfset var rc =
getRequestContext().getCollection()>
    <cfset var tempJsString = "">

    <!---
remove unused portions of scope (i.e. fieldnames,event) --->
    <cfset
tempEventScope = Duplicate(rc)>
    <cfset
StructDelete(tempEventScope,"event",false)>
    <cfset
StructDelete(tempEventScope,"coldbox_debugpanel",false)>
    
    <cfloop
collection="#tempEventScope#" item="key">
      <cfif
ISNUMERIC(TRIM(tempEventScope[key]))>
        <cfset valStr = "'" &
Replace(TRIM(tempEventScope[key]),"'","\'","all") & "'">
      <cfelse>
<cfset valStr = "'" & Replace(TRIM(tempEventScope[key]),"'","\'","all") & "'">
</cfif>
      <cfset tempJsString = tempJsString & ", " & key & " : " & valStr &
"">
    </cfloop>
    
    <cfreturn tempJsString />
  </cffunction>
</cfcomponent>
[/code]

I realize this is a rather crude example... has
anyone else done anything interesting with the request context decorator?
http://forums.coldboxframework.com/index.cfm?event=ehMessages.dspMessages&threadid=0B2540E8-FF65-CEF6-656867565E25EFFA