?
Solved

Thistag.GeneratedContent Problem

Posted on 2002-06-26
8
Medium Priority
?
323 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 2000 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
What You Need to Know when Searching for a Webhost Provider
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. 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 : Open Page or Post…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 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