This content has been marked as final. Show 9 replies
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.1 person found this helpful
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.
Thanks Tony, for your quick response!.
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.
readUrl works but consumes an app server thread, so use it with caution.
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"]
Edited by: Venkat Mohanam on Aug 6, 2012 5:21 AM
Still facing some issue with the work arounds, so re-opened this issue with my question (in the above thread)
Edited by: Venkat Mohanam on Aug 6, 2012 5:20 AM
Hi Venkat -
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...
Yes, if you view the source, the embedded asset is a A HREF tag with some custom field info in it. Your pre-processor needs to be smart enough to not mangle that string.
I would investigate the fileNotFound exception issue. That's very strange.
This can also be achieved in this way
String fieldData = ics.GetVar("fieldData");
EmbeddedLink link = new EmbeddedLink(ics,fieldData,false,false,true);
String fieldValueInString = link.evaluate();
The fieldValueInString will contain the Required Value.