3 Replies Latest reply on Mar 10, 2006 4:48 AM by jameswoodward

    Seam & Facelets

    jameswoodward Newbie

      Firstly, let me apologise for posting this in the Seam forums when it is really a Facelets question....

      I am converting a JSF application to use Seam 1.0 beta 2 and Facelets 1.0.12. I've converted the project to use Seam and everything is working fine.

      On changing to Facelets everything is also working fine except for one page which kinda relies on JSP to render an Excel spreadsheet on the fly.

      The following code works correctly when using JSP as the view handler, but when I switch over to Facelets, it renders an HTML page instead of an Excel spreadsheet.

      Is there a way of specifying the content-type in Facelets?

      Is there a way of telling Facelets to delegate the rendering to JSP?

      Any help much appreciated!

      James.

      exportSpreadsheet.jspx

      <?xml version="1.0"?>
      <jsp:root
       version="2.0"
       xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:af="http://xmlns.oracle.com/adf/faces">
       <jsp:directive.page contentType="application/vnd.ms-excel"/>
      
       <f:view>
       <f:loadBundle basename="#{initParam.messageBundle}" var="lbl"/>
       <html xmlns:x="urn:schemas-microsoft-com:office:excel">
       <head>
       <style>
       <!--table
       @page {
       mso-header-data:"&NCC Mazda Stock List\000ADate\: &D\000APage &P";
       mso-page-orientation:landscape;
       }
       br {
       mso-data-placement:same-cell;
       }
       .excelText {
       mso-number-format:General;
       text-align:left;
       }
       .excelCurrency {
       mso-number-format:Currency;
       }
       .excelNumber {
       mso-number-format:General;
       }
       -->
       </style>
       <!--[if gte mso 9]><xml>
       <x:ExcelWorkbook>
       <x:ExcelWorksheets>
       <x:ExcelWorksheet>
       <x:Name>NCC Mazda Stock List</x:Name>
       <x:WorksheetOptions>
       <x:Print>
       <x:ValidPrinterInfo/>
       </x:Print>
       </x:WorksheetOptions>
       </x:ExcelWorksheet>
       </x:ExcelWorksheets>
       </x:ExcelWorkbook>
       </xml><![endif]-->
       </head>
       <body>
       <h:dataTable value="#{partServices.allParts}" var="item" columnClasses="excelText,excelText,excelCurrency,excelCurrency,excelNumber">
       <f:facet name="header">
       <h:panelGroup>
       <h:outputText value="#{lbl.listParts}"/>
       <h:outputText value=" - "/>
       <h:outputText value="#{partServices.lastUpdate}"/>
       </h:panelGroup>
       </f:facet>
      
       <h:column >
       <f:facet name="header">
       <h:outputText value="#{lbl.partNumber}"/>
       </f:facet>
      
       <h:outputText value="#{item.partNumber}"/>
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{lbl.description}"/>
       </f:facet>
      
       <h:outputText value="#{item.description}"/>
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{lbl.purchasePrice}"/>
       </f:facet>
      
       <h:outputText value="#{item.purchasePrice}">
       <f:convertNumber type="currency"/>
       </h:outputText>
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{lbl.NCCPurchasePrice}"/>
       </f:facet>
      
       <h:outputText value="#{item.NCCPurchasePrice}">
       <f:convertNumber type="currency"/>
       </h:outputText>
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{lbl.quantityAvailable}"/>
       </f:facet>
      
       <h:outputText value="#{item.quantityAvailable}">
       <f:convertNumber groupingUsed="true" maxFractionDigits="0"/>
       </h:outputText>
       </h:column>
       </h:dataTable>
       </body>
       </html>
       </f:view>
      </jsp:root>