2 Replies Latest reply on Apr 2, 2007 2:11 PM by mariuszs

    Exporting XML with faceltes


      How to export XML files (not html or xhtml) using facelts templates etc in Seam?

        • 1. Re: Exporting XML with faceltes

          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"
           <f:view contentType="text/xml" />
           <t:dataList var="rowData" value="#{results}">

          Example 2: outputting csv
          <f:view contentType="text/csv"
          "First Item", "Second Item"
           <t:dataList var="rowData" value="#{results}">
          "#{rowData.item1}", "#{rowData.item2}"

          Hope this helps,

          • 2. Re: Exporting XML with faceltes

            Thanks for your answer, unfortunatelly, Im using seam + icefaces :(