Tracing JSF Applications with FacesTrace

The simplest way to use the “runtime debugging” JSF tool FacesTrace is to place the <ft:trace /> tag at the end of a page. Then let the library do it’s job. We’ve decided to include FacesTrace in our project for both debugging and orientation purposes. We’ve some new folks and I think it would help them to get oriented faster.

The main thing in my mind was to create an infrastructure that will enable us to use facestrace without placing the <ft:trace /> component manually to each page. In order to do this, first I’ve tried to decorate the view handler and add the facestrace component to the viewroot. The component was successfully added to the tree but does not get rendered. In JSF the component tree is created during the rendering which means, JSF does not create the component tree first and then render it. This is the reason why getChildrenCount() at encodeBegin of your custom components returns 0 since JSF creates the tree during the rendering. Anyway then I’ve tried to change the form renderer and it worked like a charm. The facestrace is rendered after </h:form> meanining at the end of our pages.

 public class TraceEnabledFormRenderer extends FormRenderer {
     public TraceEnabledFormRenderer() {

     public void encodeEnd(FacesContext context, UIComponent component) throws IOException{
         super.encodeEnd(context, component);
         ServletContext servletContext = (ServletContext)context.getExternalContext().getContext();
      boolean isTraceEnabled =      

         if(isTraceEnabled) {
             Trace trace = (Trace)context.getApplication().createComponent(Trace.COMPONENT_TYPE);

And here is the context-param to control the faces trace.


Last thing is to define the custom renderer at faces-config.


By the way, I’ve done some documentation, features, screenshots and more FacesTrace home page.

One Response to Tracing JSF Applications with FacesTrace

  1. wynton says:

    It doesn’t work. I still need add tag to my JSF file.

%d bloggers like this: