[seam-dev] Exporting datatables

Pete Muir pete.muir at jboss.org
Thu Aug 7 07:08:15 EDT 2008


On 7 Aug 2008, at 10:17, Nicklas Karlsson wrote:

> Hi,
>
> While looking for css parsing for the excel-export of datatables, I
> recalled running into https://xhtmlrenderer.dev.java.net/ before. What
> it essentially
> does is parses xhtml and converts it to pdf/image/svg, taking
> stylesheets etc into account.
>
> Does anyone here have any insight on if it would be possible in JSF
> to, given a component id, dig it out, render it to a temporary
> document, strip
> out the other components from the body with exception of the component
> to export and its parents (preserving stylesheet info), make sure it's
> xhtml compliant
> (through TagSoup or some other library), convert it to the target
> format (through the xhtmlrenderer) and hanging the result on the
> DocumentStore?

To manually render the document to a String you can do:

1) Get hold it - Component = findComponent(id)
2) Swap out the responseWriter for a wrapped StringWriter
3) Call JSF.renderChild(facesContext, cmp)
4) Restore the responseWriter
5) Get the String from the string writer is the rendered body of your  
component

I don't quite follow what you are doing in the second half of your  
sentence, but you can always remove a component from the tree by doing  
cmp.getParent().getChildren().remove(cmp); cmp.setParent(null);

>
>
> It could be handy to make in-application screenshots (targetting the
> root) to pdf/image or just to target a component (datatable) to
> export(?)
>
> ---
> Nik
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev




More information about the seam-dev mailing list