Solved

Thistag.GeneratedContent Problem

Posted on 2002-06-26
8
286 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google Maps 7 77
Annoying "thing" blocks my view 4 100
System Analysis 5 58
WEB Farm 6 69
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…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
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 update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

770 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