After reading this article showing how to create a servlet filter that will render XHTML to a PDF, image, or SVG, I was inspired to try it out as a filter in Seam using the @Filter annotation. The filter installation went smoothly but getting Flying Saucer to parse the generated JSF and css background images was not so easy.
First off, generated markup from any given JSF component is not guaranteed to be good markup. So I had to make use of cyberneko html parser. The servlet filter parses the generated response and then neko cleans up any non standard xhtml elements.
One huge css tip is make sure you declare
media="screen,print" on your xhmtl css reference. Naturally it would be good to split the 2 style sheets but laziness forced me to use one for both.
An Example Application
A few months ago, I wrote a simple website for the neighborhood I live in using Seam. I tried to start out writing this site using Ruby on Rails but I just wasn't impressed compared to what Seam offers. (Even for a small one-off website)
So below are 2 live links that show the code in action and parsing a real world example. Enjoy...
It's pretty cool not having to define a servlet filter in your web.xml. Just add the @Filter annotation to the top of the class and wala. I had to add the
within="org.jboss.seam.web.ajax4jsfFilter" attribute to the annotation so FS could render the RichFaces images/resources.
- Flying Saucer Seam component (source)
- All flying saucer jars