• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Life cycle of Java CFX tags

Guide ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm
Life cycle of Java CFX tags
A new instance of the Java CFX object is created for each invocation of the Java CFX tag. This means that it is safe to store per-request instance data within the members of your CustomTag object.

If you run the attached, the output is:

num message isOdd
2 InputCounter=2 false
3 InputCounter=3 true
4 InputCounter=4 true
5 InputCounter=5 true
6 InputCounter=6 true
7 InputCounter=7 true
9 InputCounter=9 true
11 InputCounter=11 true
13 InputCounter=13 true

If a new instance is created for each invocation, then the initial value of isOdd should be false. So why does <cfx_test inputCounter="4"> return true and not false? What am I missing?

TOPICS
Advanced techniques

Views

477

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 27, 2006 Oct 27, 2006
Yes, I thought it seemed like a bug. Thanks for the confirm.

Votes

Translate

Translate
Advisor ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

Shouldn't your link be: http://livedocs.macromedia.com/coldfusion/7/htmldocs/00001095.htm ?

Also, notice that that page says that you can use your custom tag to store data during the request.

CF only invokes the tag once per request (barring shenanigans) -- even though you call it multiple times.

That text is telling you that you do not normally have to worry about crosstalk between requests on any temporary data stored in the CFX.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

Exactly how are you defining request here? It can't be per http request because the behavior is different if you move the tag outside the cfloop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

Yeah, you are right.

The object appears to be invoked or not, willy nilly, depending on what kind of flow control structure it is in!
See the attached code.

This is definitely a bug.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

Yes, I thought it seemed like a bug. Thanks for the confirm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 28, 2006 Oct 28, 2006

Copy link to clipboard

Copied

Forgot to add:
Using an explicit tag close, IE <cfx_test inputCounter="#num#" />, has no effect.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 28, 2006 Oct 28, 2006

Copy link to clipboard

Copied

LATEST
For kicks I added hashCode() to the cfx tag response. The hashcode is always the same within the cfloop.. but different outside the loop. So the loop is definitely reusing the same object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation