Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting tagContext outside of error condition 1

Status
Not open for further replies.

csteinhilber

Programmer
Aug 2, 2002
1,291
US
I want to be able to grab the array of executed tags at any given point in a request... similar to the CFCATCH.tagContext array, but without having to be within a CFCATCH or error condition of any kind.

I imagine that doing so revolves around the GetPageContext() function... which returns a customized java PageContext object. Then... maybe GetPageContext().GetFusionContext()... but from there, I don't know where to turn.

Anybody have any insight? Basically, given a particular CustomTag, I want to know the pages/modules that executed up to the point that the CustomTag was called.

GetBaseTemplatePath() doesn't give me what I want, because there can be many many levels in between. I need the "in between".

Thanks in advance,
-Carl
 
Hi Carl, good to see you again, hope we can help you out.

so you're asking for the template that called the custom tag?

where did GetFusionContext() come from?

<cfset pc = Getbasetemplatepath().GetFusionContext()>
<cfdump var = "#pc#">
gives me "The selected method GetFusionContext was not found. "

the only documentation i've found on it comes from .net



We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
lol.
oops i ment to say

<cfset pc = GetPageContext().GetFusionContext()>
<cfdump var = "#pc#">
gives me "The selected method GetFusionContext was not found."

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Hey man. Can't believe I've been away so long... been real busy ;)

Anyway... odd that you get no joy with the GetFusionContext().

Here's what I have:

Code:
[i]Page "basepage.cfm":[/i]

<HTML>
<HEAD>
    <TITLE>Context</TITLE>
</HEAD>

<BODY>
    <CFMODULE name="devtags.contexttester">
</BODY>
</HTML>

Code:
[i]Module "contexttester.cfm"[/i]

<!--- I am just here to test the contextsniffer module... to add an extra layer of hierarchy --->

<cfoutput><p>We hit the tester module</p></cfoutput>

<CFMODULE name="devtags.contextsniffer">

Code:
[i]Module "contextsniffer.cfm"[/i]

<!--- I attempt to dump the tag/module context of the particular module --->

<CFSET stPageContext = GetPageContext()>

<CFDUMP var="#stPageContext.GetFusionContext()#">

I get a dump of a "object of coldfusion.filter.FusionContext"

Code:
Methods:
   getRealPath (returns java.lang.String)
   getServlet (returns interface javax.servlet.Servlet)
   getServletContext (returns interface javax.servlet.ServletContext)
   getCurrent (returns coldfusion.filter.FusionContext)
   getSession (returns interface javax.servlet.http.HttpSession)
   getRequest (returns interface javax.servlet.http.HttpServletRequest)
   getResponse (returns interface javax.servlet.http.HttpServletResponse)
   addExceptionHandler (returns void)
   getStartTime (returns java.util.Date)
   getPagePath (returns java.lang.String)
   getSecurePassword (returns java.lang.String)
   getSecureUsername (returns java.lang.String)
   getApplicationEventEnableStatus (returns boolean)
   SymTab_finalizeAfterRequest (returns void)
   setApplicationEventEnableStatus (returns void)
   SymTab_setApplicationScope (returns void)
   SymTab_setSessionScope (returns void)
   SymTab_setClientScope (returns void)
   setValidationErrorHandler (returns void)
   setRequestErrorHandler (returns void)
   SymTab_popActiveScope (returns void)
   SymTab_initForRequest (returns void)
   setSecureCredentials (returns void)
   SymTab_pushActiveScope (returns void)
   SymTab_pushActiveScope (returns void)
   setIsRemoting (returns boolean)
   isRemoting (returns boolean)
   setCurrent (returns coldfusion.filter.FusionContext)
   createContextData (returns coldfusion.filter.FusionContext$FusionContextData)
   getEventContext (returns coldfusion.eventgateway.EventContext)
   setUseMappings (returns boolean)
   getUseMappings (returns boolean)
   setApplicationName (returns void)
   setServletObjects (returns void)
   getSecureTable (returns coldfusion.runtime.SecurityTable)
   getFormScope (returns coldfusion.filter.FormScope)
   getRequestContent (returns [B)
   setSecureTable (returns void)
   getApplicationName (returns java.lang.String)
   setPagePath (returns void)
   setEventContext (returns void)
   hashCode (returns int)
   getClass (returns java.lang.Class)
   wait (returns void)
   wait (returns void)
   wait (returns void)
   equals (returns boolean)
   notify (returns void)
   notifyAll (returns void)
   toString (returns java.lang.String)

Properties:
   SymTab_orderCGI = 0
   pageContext = class coldfusion.runtime.NeoPageContext
   application = interface javax.servlet.ServletContext  
   config =  interface javax.servlet.ServletConfig  
   hiddenScope = class coldfusion.runtime.Scope  
   formScope = class coldfusion.filter.FormScope  
   fileScope = class coldfusion.runtime.LocalScope  
   secureTab = [undefined value]  
   request = interface javax.servlet.http.HttpServletRequest  
   response = interface javax.servlet.http.HttpServletResponse  
   servlet = interface javax.servlet.Servlet  
   instance = [undefined value]  
   parent = class coldfusion.runtime.CFPage  
   parentTag = [undefined value]  
   args = class coldfusion.runtime.ArgumentCollection  
   returnValue = [undefined value]  
   exceptionHandlers = [undefined value]  
   requestExceptionHandler = [undefined value]  
   validationExceptionHandler = [undefined value]  
   eventContext = [undefined value]  
   formCounter = 1  
   includeJavascriptLib = YES  
   formNames = class java.util.ArrayList

... but I don't even know if the FusionContext object is really the one I'm after... just seemed like a logical choice.

If you try to dump just the GetPageContext()... do you get anything? We're running MX7 as a J2EE server... maybe there's a difference in setup that would prevent you from using the object?

Or... maybe you have another idea of how to get the same info. Basically, I would really like to get back an array like:
Code:
(1) basepage.cfm
   :
   :
(x) contexttester.cfm
(x +1) contextsniffer.cfm

but I would settle for just getting back "contexttester.cfm" if that's all we can get.


Thanks!
-Carl


 
Carl,
I haven't been able to work with GetPageContext().GetFusionContext() however I've played with some of the other methods returned by getPageContext and Can't seem to get what you're after. I even tried to "hack" it by making intentionly breaking it, catch the cferror variables using cftry/cfcatch but couldn't get that to work either.

Sorry I couldn't come through for you :(

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
csteinhilber

Someone recently asked me about this on another list and its one of those things I have been meaning to look into for ages. I had a little rumage around and this is what I came up with - haven't had a chance to take it all the way but if I get a chance over the weekend I will see if I can get but the results in a more meaningful way and wrap it in a cfc.

Create a dummy page which we will include in another page later to see if it turns up in the information made availabl e later:

Code:
 test10.cfm
<cfset iLikeToEat = "chicken" >

Code:
 test31.cfm

<cfinclude template="test10.cfm" >

<cfscript>
factory = createObject("java","coldfusion.server.ServiceFactory");
</cfscript>

<cfset debuggingEvents = factory.getDebuggingService().getDebugger().getData()>

<cfdump var="#debuggingEvents#" >

couple of things about this - first and foremost it uses the cf service factory which are undocumented in cfmx 6.0,6.1 but exposed as the all new shiny administrator api in cfmx7 (one of my favourite features of cfmx7 :) )

Secondly on a whim I just tested this and you need to have debugging switched on in the administrator. Now if this is for a production system you probably do not want to do this *however* again using the cfmx7 administrator api you may be able to programmatically switch it on off.

Hope its some help despite the obvious disadvantages.
 
Incidentally I'm using 6.1 (J2EE) and GetPageContext().GetFusionContext() doesn't work for me either

<cfdump var="#GetPageContext().getPage()#" >

seems to return methods similar to the ones you listed above

actually just remembered I do also have CFMX 7 on this machine and tried it out and it works so it seems that this is a change from cfmx6.1.

 
Thanks pigsie.

For some reason getData() doesn't seem to store every template in the stack. I'm using a framework, and I'm getting Application.cfm, and a view template in my result set... but not the individual modules. I'm not sure why. But I do like the direction you're pointing me in, so I gave you a star :)

I'll keep investigating.

For now, I just wimped out and create an error condition with a CFTHROW:
Code:
    :
   <CFTRY>
      <CFTHROW>
   <CFCATCH type="any">
      <CFSET arTemplateStack = CFCATCH.tagContext>
   </CFCATCH>
   </CFTRY>
    :

I'm a little concerned about overhead and performance (how long it takes to throw and catch) which is why I didn't want to go that route initially... but it does what I need and I had to get it out quickly.





-Carl
 
okay, let me know if you do manage to get any further with that, so far the option you have chosen seems to be the option everyone has chosen.

I know MM have been soliciting for ideas for scorpio (CF8) so I may suggest to Tim Buntel they make it easier to extract this information - they have gone quite some way to exposing some of the internals in the cfadmin api but it would be nice to have a cleaner way to glean this information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top