Skip to main content
Inspiring
October 28, 2006
Answered

Life cycle of Java CFX tags

  • October 28, 2006
  • 1 reply
  • 643 views
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?

This topic has been closed for replies.
Correct answer cf_dev2
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.

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

1 reply

October 28, 2006
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.

cf_dev2Author
Inspiring
October 28, 2006
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.
October 28, 2006
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.