Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

My little templating snafu

$
0
0

CF10/Win7Prox64

 

I have a TemplatingService object.  It has it's processTemplate() function called and is passed 1 argument, a Request object which holds information about the request.

 

The first thing it does is execute the controller in the Request object like so:

 

<cfinclude template="#arguments.Request.getController()#" />

 

This works perfectly, as the controller file is included and executed.  Well, I'd like that controller file to be able to call functions IN the TemplateService in order to modify things about itself, and though this is easily possible by writing:

 

<cfset doSomeFunction( Request = arguments.Request, data=foo ) />

 

Something about having to constantly self-reference the request bugs me.  I understand OOP and know that objects need to be passed, but is there ANY way you can think of where I could make the aforementioned call like:

 

<cfset doSomething( data=foo ) />

 

Which would look for a doSomething() function in the TemplateService object, but automatically send the Request object as well.  Maybe some kind of proxy object?  I've tried putting an onMissingMethod in the TemplateService, and it captures the request when I omit the function from TemplateService() but I don't have access to the Request object.  I've even tried wrapping the call to doSomething() in a cftry and then capturing the error, but even though I can then pass the Request object, I don't have access to the params that were intended to be sent to the function.

 

Ideas?


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>