As we know, the render:stream will always stream the output to the browser. I have a requirement where I need to process the output of render stream at the server side and print it. So I tried using ics.ReadPage and called a siteentry/csElement which has the code <render:stream variable="myvalriable"/>. But still I get the unprocessed output in the ics.ReadPage, calling the SiteEntry. Appreciate your help regarding this.
The short answer is no. The longer answer is that readPage will work, if the page you're reading is cached. You can also use AJAX but that would mean your code flow would change quite a bit.
I assume you're going to want to do some processing on the output of render:stream. You might want to consider doing the processing first, then setting the result into a variable and then calling render:stream on the variable instead. In other words, process first, then stream.
Basically I need to pass this output to a js function like below.
The render stream output content may have single quote and double quotes, which is breaking the js function call. So, I tried, like below
<div id='my-div' style='display:none'><render:stream variable='myvariable'/></div>
This works fine, but there is an extra <p> tags added in the output due to FCKEditor's default behavior, whenever the embedded template has some html tags like div in this case.
So, Unless I get the renderstream content at the server side and parse it to escape all single and double quotes, I cannot get away with this issue.
Markley has suggested to call the page using the url instead of readPage. Now we use Utilities.readURL , which perfectly returns the processed content. Now we are able to parse it and escape all single and double quotes and pass it to js function. So, this resolves the issues.
That's exactly correct Tony!.
We get FileNotFound exception when we use Utilities.readUrl. This exception goes off, when we restart the system. We were really struggling on this issue for the past 2 days.
Do you suggest any work around to get away with this issue?
Also, I was trying your option, to encode/escape the value in render:stream. But I couldn't find out encode/escape attributes in render:stream tag. Could you please give us a sample code to implement in this way. Appreciate your response Tony and thanks for your time. Below is the syntax I could see in the guide. Where do we supply the attribute encode/escape in the below tag?
[ssvariable="session variable name"]
Sorry, my mistake! I was thinking of the escape/encode attributes on the [xlat:stream] tag - I assumed it was a pattern across the stream tags but apparently not.
There is no way to get the output of render:stream in a variable programmatically without going through the servlet's front door. There isn't even a back door, it has to do with the way the functionality is built. It is a tricky problem to fix and it must be done by engineering.
Your best bet is to
a) see if you can accomplish the same thing a different way
b) use readURL (with a URL that actually works).
For a), have you considered retrieving your data into a variable, processing it, then calling render:stream on the variable instead of the asset field?
That's fine, no problem Tony. Thanks for your response.
For option a) if I escape the single and double quotes on the asset value before passing it to render:stream, the element execution fails, because the content contains someother include (embedded asset). Below is the sample text that I am trying to escape.
Customers for a wide range of solutions: <span id="_CSEMBEDTYPE_=inclusion&_PAGENAME_=FirstSiteII%2FDocument_C%2FDocumentDisplay&_cid_=1299863431444&_c_=Document_C"><i>[Asset Included(Id:1299863431444;Type:Document_C)]</i></span>Web sites, product marketing sites and partner extranets. For more information click here
I guess, even the render engine looks for some specific double quotes to process the embed tag. As all the quotes are escaped by my script, the element execution itself is failing.
For option b) the ics.readUrl sometimes throws filenotfound exception and it gets resolved only when we restart the system.
Please suggest. Thanks for your suggestion and time...