Solved

Thistag.GeneratedContent Problem

Posted on 2002-06-26
8
277 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
  • 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now