Copy link to clipboard
Copied
In short, my onCFCRequest() method makes a manual invokation of the component and sends it the arguments.
Let's say, for example, I am calling a component located at www.coms.template
Is it possible for me to do something in a method called in that template component so that when it returns the generated content and we are now back in the onCFCRequest() method, that I can look at the generated content and determine/set/serve the appropriate mimetype?
My methods can generate JSON, WDDX, CSS, Javascript and HTML, and I want to make sure they serve as the appropriate mimetypes when their content is sent to the browser:
Well... you know what content you're generating, so the calling code needn't guess, you can just tell it. Return a struct which has the response data in one key, ans the type in another.
And you set the MIME type for a response using <cfcontent>
--
Adam
Copy link to clipboard
Copied
Well... you know what content you're generating, so the calling code needn't guess, you can just tell it. Return a struct which has the response data in one key, ans the type in another.
And you set the MIME type for a response using <cfcontent>
--
Adam
Copy link to clipboard
Copied
Ah! Like having the component.cfc set something into the URL scope (like a variable called 'returnType') so that when we get back to the onCFCRequest() it can read the value and say "Oh! It looks like that component wanted to return it's data as: XML, I'll set the mimetype accordingly.
That makes sense.
** UPDATE ** AND IT WORKS!
Had to do some fannageling, but I got it. It now properly outputs content in JSON (application/json), WDDX/XML (text/xml), Javascript (application/javascript), CSS (text/css), HTML (text/html) and Text (text/plain).
I did a test and had the component generate HTML code but tell the oCFCR() to serve it up as text and sure enough, it did not evalute the paragraph tags, but displayed them like text. BRILLIANT!