Search code examples
htmljsfrichfacesformatseam2

Format the actual HTML to be readable with SeamFramwork


Is there a way to format the actual HTML into readable (nicely formatted) text when generating xhtml pages from SeaMFramework.

I want to be able to rightclick on my webpages and view-source where the html and javascript is well formated (tabbed, new lines). I'm using JSF and Richfaces which genreates their own html and javascripts which I want more readable.


Solution

  • You can use the JTidyFilter for this. Download jtidyservlet.jar, drop it in /WEB-INF/lib and register the filter as follows in web.xml:

    <filter>
        <filter-name>jTidyfilter</filter-name>
        <filter-class>org.w3c.tidy.servlet.filter.JTidyFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>jTidyfilter</filter-name>
        <url-pattern>*.jsf</url-pattern> <!-- Or whatever you're using for JSF -->
    </filter-mapping>
    

    I would personally not care about this. The filter has a significant performance impact and browser's developer tools like Chrome/Firebug/IE9 already shows nicely formatted HTML on F12. It are anyway the (puristic) developers who care about this, not "dumb" endusers.