Pages

Wednesday, April 23, 2008

Get JSF trace and performance info with Faces Trace

On the serverside I saw a great post about Faces Trace with this library you can get trace information and performance information of the jsf page. The trace and performance information can be displayed on the jsf page. Here an example how it looks

You can also see this demo page
In this blog I will show you can use this library in your jsf pages created with jdeveloper.
The first step is to download the jar file and add this to the project libraries.
We also have to make a new taglib entry. Go the project options and go the jsp tag libraries entry and click the add button.

Click user( top of the page ) then new and select the faces trace jar file.

This is how it looks. It uses the ft prefix.
Now we can add a context parameter to the web.xml so we can disable the trace information in production

<context-param>
<param-name>com.prime.facestrace.DISABLE_TRACE</param-name>
<param-value>false</param-value>
</context-param>

The last step is to add faces trace to the jsf page. We add the following line xmlns:ft="http://facestrace.sourceforge.net" to jsp:root element.

<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces"
xmlns:afh="http://xmlns.oracle.com/adf/faces/html"
xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable"
xmlns:ft="http://facestrace.sourceforge.net">
<jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>

Add <ft:trace/> under the end tag of the body element

</body>
<ft:trace/>
</html>
</f:view>
</jsp:root>

We are ready to test the jsf page

5 comments:

  1. Hi there,

    Just curious if you've seen this problem: http://forums.oracle.com/forums/thread.jspa?messageID=1875670

    when using faces trace?

    Best regards,

    John

    ReplyDelete
  2. Hi John,

    The visual editor of the jsf page looks fine, I use jdev 10.1.3.3

    ReplyDelete
  3. Thank you for showing a great tool.

    ReplyDelete
  4. Hi,

    I have followed what you have mentioned in the blog. I have added also in the page. But where do I see this trace information ?

    ReplyDelete
  5. Hi,

    you should see it on the page, you can't miss it.

    don't know if this works.

    thanks

    ReplyDelete