4 Replies Latest reply on Oct 5, 2007 11:26 AM by Aymen

    specify content type for XHMTL

    Aymen Newbie

      Hi,
      I would like to know if it is possible and how to specify content-type for an XHTML Page. I need this to generate an xls(excel) file.
      Pleaaase some help!

        • 1. Re: specify content type for XHMTL
          Samuel Mendenhall Apprentice

          use the following in the page you want to be excel:

          <f:view contentType=".....">
          
          </f:view}
          


          where ..... is the excel mime type

          • 2. Re: specify content type for XHMTL
            Aymen Newbie

            I've already tryied that but it didn't work. I tried:

            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:f="http://java.sun.com/jsf/core">
            <head>
            <title>Page XHTML</title>
            <meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=iso-8859-1" /> </head>
            <body>
            <f:view contentType="application/vnd.ms-excel">
             <table>
             <tr>
             <td>1</td>
             <td>2</td>
             <td>3</td>
             </tr>
             <tr>
             <td>4</td>
             <td>5</td>
             <td>6</td>
             </tr>
             </table>
             </f:view>
            </body>
            </html>


            And I got this error message:

            java.lang.IllegalArgumentException: ContentTypeList does not contain a supported content type: application/vnd.ms-excel
             at org.apache.myfaces.renderkit.html.HtmlRendererUtils.selectContentType(HtmlRendererUtils.java:964)
            ...


            • 3. Re: specify content type for XHMTL
              Samuel Mendenhall Apprentice

              The myfaces HtmlRendererUtils doesn't look like it takes into account any other content types except text/html and application/xhtml+xml. JSF 1.2 RI on the other hand correctly handles it. So you can move to Seam 2.0 and JBoss 4.2, or you can just upgrade your existing project/JBoss to use JSF 1.2 RI, see the documentation. After that use the following:

              <?xml version="1.0" encoding="ISO-8859-1" ?>
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich">
              
               <ui:composition>
               <f:view contentType="application/vnd.ms-excel">
               <table>
               <tr>
               <td>1</td>
               <td>2</td>
               <td>3</td>
               </tr>
               <tr>
               <td>4</td>
               <td>5</td>
               <td>6</td>
               </tr>
               </table>
               </f:view>
               </ui:composition>
              
              </html>
              


              • 4. Re: specify content type for XHMTL
                Aymen Newbie

                Hi
                finally I migtrated to Seam 2.0.0.CR1 but your exemple still doesnt work!
                Help