Solved

Thistag.GeneratedContent Problem

Posted on 2002-06-26
8
303 Views
Last Modified: 2013-12-24
Hi

I have a problem with thistag.GeneratedContent.

Here what i want to do

Calling Template Code

<cfset Var_text = "this is a test statement">
<cf_calltag >
#Var_text#
</cf_calltag>


Here is calltag.cfm code

<CFIF thistag.ExecutionMode EQ "end">

<CFSET Test = thistag.GeneratedContent>

<cfoutput>#Test#</cfoutput>
<CFSET thistag.GeneratedContent ="">
</CFIF>

I want that output should be "this is a test statement" but it displays "#Var_text#". I have used evaluate function as well but in vain.

I am using nested tags and I want manipulation on the basis of "thistag.generatedcontent" value.

In the ColdFusion documentation they clearly written that thistag.GeneratedContent evaluate all coldfusion variables and function along with text and html. I am copying their description here.

"Custom tags can access and modify the generated content of any of its instances using the thisTag.GeneratedContent variable. In this context, the term generated content means the results of processing the body of a given tag. This includes all text and HTML code in the body, the results of evaluating ColdFusion variables, expressions, and functions, and the results generated by descendant tags. Any changes to the value of this variable results in changes to the generated content."

Does any one have any clue about this.

Thanks
0
Comment
Question by:Barraq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:heathprovost
ID: 7110111
You are mis-interpreting their description of this... The page in which the tag is called is what processes the body of a customtag, not the customtag itself (at lest when you do it the way you are describing).  The customtag recieves the _output_ of this processing, not the CF code which produced it. You are free to do anything you want with this output, including modifying it, but this variable will always contain the output of code, not the code itself...

The code you listed will work correctly if done like this:

Calling Template Code

<cfset Var_text = "this is a test statement">
<cf_calltag >
<cfoutput>#Var_text#</cfoutput> <!---added cfoutput here--->
</cf_calltag>


Here is calltag.cfm code

<CFIF thistag.ExecutionMode EQ "end">

<CFSET Test = thistag.GeneratedContent>

<cfoutput>#Test#</cfoutput>
<CFSET thistag.GeneratedContent ="">
</CFIF>

This of course may not be the effect you desire. Could you describe exactly what you are trying to accomplish?

Heath
0
 

Author Comment

by:Barraq
ID: 7110160
Actualy I am trying to write down a replacement of cfmail tag. We have written an EMAIL SMTP Service using IMAP4.

What i want is that a replacement of cfmail as that user only have to replace cfmail with cf_mail and rest will work as it is. Using <cfoutput> (which is not required for cfmail tag) my cf_mail works properly but I don't want to use cfoutput tag.

Regarding thistag.GeneratedContent I still think it should have to do that as if you write down any cf function like Now() without cfoutput and use
<cfoutput>Evaluate("thistag.GeneratedContent")</cfoutput> in the calling tag then it will display the system date. Problem arrives only when I use variables while in the document they clearly mentioned it that it will also evaluate the ColdFusion variables as well. As it can manipulate cf function it should have to manipulate ColdFusion variables.

Am i still wrong. Please reply if is it possible or not?

thanks

0
 
LVL 5

Accepted Solution

by:
heathprovost earned 500 total points
ID: 7115321
Im sorry but what you are trying to do is basically impossible using CF custom tags... The use of the cfoutput tags is pretty much required to acheive the effect you are looking for. Either that, our you would have to write a CFX binary tag.  

The reason Now() works when you use evaluate from the custom tag is because Now() is a function and is not limited in any way by scope.  Variables, on the other hand, always have a defined scope. Most of the variables which would be used in a CFMAIL tags body would tend to be either page level or query variables (of course technically it could be pretty much anything).

The problem is that CF isolates the customtag from the most of the scopes in the calling template. Page and Query variables are not directly accesible from your customtag, it cant see these scopes directly.  If you tried to do this using evaluate, you would find that CF will give errors because the variables are undefined... Like I said before, the documentation is NOT wrong, you are just reading too much into it. evaluate() can easily process variables, but it must be able to SEE them.

On the other hand, some scopes, like application, session, request, etc. are accessible, but I think it would be more troublesome to require the coder to make sure all variables are in a certain scope than to just make them use CFOUTPUT around the body...

I know this isnt what you wanted to hear, but I really dont know any other way of doing this other than requiring the coder to place cfoutputs around the tag body...

Heath
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
LVL 10

Expert Comment

by:substand
ID: 9045394
you still need help on this?
0
 

Author Comment

by:Barraq
ID: 9046673
hi substand

Yes Please if you can
0
 
LVL 10

Expert Comment

by:substand
ID: 9051411
actually, after reading all of that... i have to go with heathprovost... i think you should accept that answer.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10794231
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Accept heathprovost

Please leave any comments here within the next four days.

mrichmon
EE Cleanup Volunteer
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IPA - can it be run on a web server? 3 247
Google Maps 7 83
Tool to email me when a website changes 29 146
cookies analysis tools 2 110
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question