-
1. Re: Exporting XML with faceltes
pbrewer_uk Apr 2, 2007 7:52 AM (in response to mariuszs)This is really just a jsf question, but you can acheive this just like exporting to html - with one key difference, you must include the f:view tag with a content type of text/xml. Although I have used facelet templates with this technique, I assume the examples below can easily be adapted.
Note 1: You can specify content types other than text/xml - if you do, make sure the f:view encloses your output document - facelets will only parse valid xml.
Note 2: This will not work with icefaces - its direct to dom rendered expects a dom tree with root element of html (haven't checked this with 1.6 releases though).
Note 3: Seam now provides a way of outputting pdf documents using jsf tags - see seam docs!
Example 1: outputting xml<?xml version="1.0" encoding="utf-8" ?> <myXmlRoot xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:f="http://java.sun.com/jsf/core"> <f:view contentType="text/xml" /> <t:dataList var="rowData" value="#{results}"> <myItem>#{rowData.description}</myItem> </t:dataList> </myXmlRoot>
Example 2: outputting csv<f:view contentType="text/csv" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk"> "First Item", "Second Item" <t:dataList var="rowData" value="#{results}"> "#{rowData.item1}", "#{rowData.item2}" </t:dataList> </f:view>
Hope this helps,
Pete -
2. Re: Exporting XML with faceltes
mariuszs Apr 2, 2007 2:11 PM (in response to mariuszs)Thanks for your answer, unfortunatelly, Im using seam + icefaces :(