Leonardo,

I think you forgot to also update this:
http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/licenses/

this is very important, since we keep track of all licenses here.
iText is MPL.

Can you please update?

Thanks,
Matthias

On Sat, Apr 5, 2008 at 4:28 AM,  <[EMAIL PROTECTED]> wrote:
> Author: lu4242
>  Date: Fri Apr  4 19:28:48 2008
>  New Revision: 645018
>
>  URL: http://svn.apache.org/viewvc?rev=645018&view=rev
>  Log:
>  fix TOMAHAWK-1229 PDF Export Component (thanks to Hazem Saleh)
>
>  Added:
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/
>     
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>    (with props)
>     
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>    (with props)
>     myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp   
> (with props)
>  Modified:
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
>     
> myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
>     myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
>     
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
>     myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,87 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.custom.pdfexport;
>  +
>  +import javax.faces.component.UIComponentBase;
>  +import javax.faces.context.FacesContext;
>  +import javax.faces.el.ValueBinding;
>  +
>  +import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
>  +
>  +public class PDFExport extends UIComponentBase {
>  +
>  +       public static final String COMPONENT_TYPE = 
> "org.apache.myfaces.PDFExport";
>  +       public static final String COMPONENT_FAMILY = 
> "org.apache.myfaces.Export";
>  +       private static final String DEFAULT_RENDERER = 
> "org.apache.myfaces.PDFExportRenderer";
>  +
>  +       private String _for;
>  +       private String _filename;
>  +
>  +       public PDFExport() {
>  +               setRendererType(DEFAULT_RENDERER);
>  +       }
>  +
>  +       public String getFamily() {
>  +               return COMPONENT_FAMILY;
>  +       }
>  +
>  +
>  +       public boolean getRendersChildren() {
>  +               return true;
>  +       }
>  +
>  +       public String getFor() {
>  +               if (_for != null)
>  +                       return _for;
>  +
>  +               ValueBinding vb = getValueBinding("for");
>  +               return vb != null ? 
> RendererUtils.getStringValue(getFacesContext(), vb) : null;
>  +       }
>  +
>  +       public void setFor(String forValue) {
>  +               _for = forValue;
>  +       }
>  +
>  +       public String getFilename() {
>  +               if (_filename != null)
>  +                       return _filename;
>  +
>  +               ValueBinding vb = getValueBinding("filename");
>  +               return vb != null ? 
> RendererUtils.getStringValue(getFacesContext(), vb) : getFor();
>  +       }
>  +
>  +       public void setFilename(String filename) {
>  +               this._filename = filename;
>  +       }
>  +
>  +       public Object saveState(FacesContext context) {
>  +               Object values[] = new Object[3];
>  +               values[0] = super.saveState(context);
>  +               values[1] = _for;
>  +               values[2] = _filename;
>  +               return ((Object) (values));
>  +       }
>  +
>  +       public void restoreState(FacesContext context, Object state) {
>  +               Object values[] = (Object[]) state;
>  +               super.restoreState(context, values[0]);
>  +               _for = (String) values[1];
>  +               _filename = (String) values[2];
>  +       }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExport.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,216 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.custom.pdfexport;
>  +
>  +import java.io.ByteArrayOutputStream;
>  +import java.io.IOException;
>  +import java.util.ArrayList;
>  +import java.util.List;
>  +import java.util.Map;
>  +
>  +import javax.faces.component.UIColumn;
>  +import javax.faces.component.UIComponent;
>  +import javax.faces.component.ValueHolder;
>  +import javax.faces.component.html.HtmlDataTable;
>  +import javax.faces.context.FacesContext;
>  +import javax.faces.event.PhaseEvent;
>  +import javax.faces.event.PhaseId;
>  +import javax.faces.event.PhaseListener;
>  +import javax.servlet.ServletOutputStream;
>  +import javax.servlet.http.HttpServletResponse;
>  +
>  +import org.apache.myfaces.custom.pdfexport.util.PDFExportConstants;
>  +import org.apache.myfaces.custom.util.ComponentUtils;
>  +import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
>  +import org.apache.poi.hssf.usermodel.HSSFCell;
>  +import org.apache.poi.hssf.usermodel.HSSFRow;
>  +import org.apache.poi.hssf.usermodel.HSSFSheet;
>  +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
>  +
>  +import com.lowagie.text.Document;
>  +import com.lowagie.text.DocumentException;
>  +import com.lowagie.text.pdf.PdfPTable;
>  +import com.lowagie.text.pdf.PdfWriter;
>  +
>  +public class PDFExportPhaseListener implements PhaseListener {
>  +
>  +       /*
>  +        * This method is used for adding the columns headers to the 
> pdfTable.
>  +        */
>  +       private void addColumnHeaders(PdfPTable pdfTable, List columns) {
>  +
>  +               for (int i = 0; i < columns.size(); i++) {
>  +                       UIColumn column = (UIColumn) columns.get(i);
>  +                       UIComponent columnHeaderCell = column.getHeader();
>  +                       if (columnHeaderCell instanceof ValueHolder) {
>  +                               String cellValue = 
> RendererUtils.getStringValue(FacesContext
>  +                                               .getCurrentInstance(), 
> columnHeaderCell);
>  +                               pdfTable.addCell(cellValue);
>  +                       }
>  +               }
>  +       }
>  +
>  +       /*
>  +        * This method is used for adding the columns values to the pdfTable.
>  +        */
>  +       private void addColumnValues(PdfPTable pdfTable, List columns,
>  +                       HtmlDataTable dataTable) {
>  +
>  +               int numberOfColumns = columns.size();
>  +               int numberOfRows = dataTable.getRowCount();
>  +
>  +               for (int i = 0; i < numberOfRows; ++i) {
>  +                       dataTable.setRowIndex(i);
>  +                       for (int j = 0; j < numberOfColumns; ++j) {
>  +                               UIComponent valueHolder = (UIComponent) 
> ((UIColumn) columns
>  +                                               
> .get(j)).getChildren().get(0);
>  +                               if (valueHolder instanceof ValueHolder) {
>  +                                       String cellValue = 
> RendererUtils.getStringValue(
>  +                                                       
> FacesContext.getCurrentInstance(), valueHolder);
>  +                                       pdfTable.addCell(cellValue);
>  +                               }
>  +                       }
>  +               }
>  +       }
>  +
>  +       /*
>  +        * This method is used for creating the PDFTable model.
>  +        */
>  +       private PdfPTable generatePDFTableModel(FacesContext facesContext,
>  +                       HtmlDataTable dataTable) {
>  +
>  +               int numberOfColumns;
>  +               List columns = null;
>  +               PdfPTable pdfTable = null;
>  +
>  +               // getting the HTMLDataTable Columns.
>  +               columns = ComponentUtils.getHTMLDataTableColumns(dataTable);
>  +
>  +               if (columns.size() == 0) {
>  +                       return null;
>  +               } else {
>  +                       numberOfColumns = columns.size();
>  +               }
>  +
>  +               // creating the PDF Table.
>  +               pdfTable = new PdfPTable(numberOfColumns);
>  +
>  +               addColumnHeaders(pdfTable, columns);
>  +
>  +               addColumnValues(pdfTable, columns, dataTable);
>  +
>  +               return pdfTable;
>  +       }
>  +
>  +       /*
>  +        * This method is responsible for writing the PDF to the response 
> stream.
>  +        */
>  +       private void generatePDF(FacesContext facesContext,
>  +                       HttpServletResponse response, String fileName,
>  +                       HtmlDataTable dataTable) throws Exception {
>  +
>  +               int currentRowIndex;
>  +               Document document = new Document();
>  +               ByteArrayOutputStream byteArrayStream = new 
> ByteArrayOutputStream();
>  +               PdfWriter.getInstance(document, byteArrayStream);
>  +               PdfPTable pdfTable = null;
>  +
>  +               currentRowIndex = dataTable.getRowIndex();
>  +
>  +               // generate the PDF table model.
>  +               pdfTable = generatePDFTableModel(facesContext, dataTable);
>  +
>  +               // open the document and write the generated PDF.
>  +               document.open();
>  +               document.add(pdfTable);
>  +               document.close();
>  +
>  +               // write the response headers.
>  +               setResponseHeaders(response, byteArrayStream, fileName);
>  +
>  +               dataTable.setRowIndex(currentRowIndex);
>  +
>  +       }
>  +
>  +       /*
>  +        * This method is used for setting the response headers.
>  +        */
>  +       private void setResponseHeaders(HttpServletResponse response,
>  +                       ByteArrayOutputStream byteArrayStream, String 
> fileName)
>  +                       throws IOException {
>  +
>  +               // setting response headers.
>  +               response.setHeader("Expires", "0");
>  +               response.setHeader("Cache-Control",
>  +                               "must-revalidate, post-check=0, 
> pre-check=0");
>  +               response.setHeader("Pragma", "public");
>  +               response.setHeader("Content-disposition", 
> "attachment;filename="
>  +                               + fileName + ".pdf");
>  +
>  +               // setting the content type.
>  +               response.setContentType("application/pdf");
>  +
>  +               // the contentlength is needed for MSIE.
>  +               response.setContentLength(byteArrayStream.size());
>  +
>  +               // write ByteArrayOutputStream to the ServletOutputStream.
>  +               ServletOutputStream outputStream = 
> response.getOutputStream();
>  +
>  +               byteArrayStream.writeTo(outputStream);
>  +               outputStream.flush();
>  +       }
>  +
>  +       public void afterPhase(PhaseEvent phaseEvent) {
>  +               FacesContext facesContext = phaseEvent.getFacesContext();
>  +               Map map = 
> facesContext.getExternalContext().getRequestParameterMap();
>  +
>  +               if (map.containsKey(PDFExportConstants.PDF_EXPORT_TABLE_ID)) 
> {
>  +
>  +                       // getting pdf file input parameters.
>  +                       String tableId = (String) map
>  +                                       
> .get(PDFExportConstants.PDF_EXPORT_TABLE_ID);
>  +                       String filename = (String) map
>  +                                       
> .get(PDFExportConstants.PDF_EXPORT_FILE_NAME);
>  +                       HtmlDataTable dataTable = (HtmlDataTable) 
> ComponentUtils
>  +                                       .findComponentById(facesContext,
>  +                                                       
> facesContext.getViewRoot(), tableId);
>  +
>  +                       // generate the PDF to the response stream.
>  +                       try {
>  +                               HttpServletResponse response = 
> (HttpServletResponse) facesContext
>  +                                               
> .getExternalContext().getResponse();
>  +
>  +                               generatePDF(facesContext, response, 
> filename, dataTable);
>  +                               
> facesContext.getApplication().getStateManager()
>  +                                               
> .saveSerializedView(facesContext);
>  +                               facesContext.responseComplete();
>  +                       } catch (Exception exception) {
>  +                               throw new RuntimeException(exception);
>  +                       }
>  +               }
>  +       }
>  +
>  +       public void beforePhase(PhaseEvent phaseEvent) {
>  +               //do nothing
>  +       }
>  +
>  +       public PhaseId getPhaseId() {
>  +               return PhaseId.RESTORE_VIEW;
>  +       }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportPhaseListener.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,79 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.custom.pdfexport;
>  +
>  +import java.io.IOException;
>  +
>  +import javax.faces.component.UIComponent;
>  +import javax.faces.context.FacesContext;
>  +
>  +import org.apache.commons.lang.StringUtils;
>  +import org.apache.myfaces.custom.pdfexport.util.PDFExportConstants;
>  +import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
>  +import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
>  +
>  +public class PDFExportRenderer extends HtmlRenderer {
>  +
>  +       public void encodeChildren(FacesContext facesContext, UIComponent 
> component)
>  +                       throws IOException {
>  +               if (component.getChildCount() == 0)
>  +                       return;
>  +
>  +               PDFExport pdfExport = (PDFExport) component;
>  +               UIComponent child = (UIComponent) 
> component.getChildren().get(0);
>  +
>  +               if (!isDecorated(facesContext, child, pdfExport))
>  +                       decorateOnClick(facesContext, child, pdfExport);
>  +
>  +               RendererUtils.renderChildren(facesContext, component);
>  +       }
>  +
>  +       private boolean isDecorated(FacesContext facesContext, UIComponent 
> child,
>  +                       PDFExport pdfExport) {
>  +               String onClick = (String) 
> child.getAttributes().get("onclick");
>  +               String jsCall = getJSCall(facesContext, pdfExport);
>  +
>  +               if (onClick == null || onClick.indexOf(jsCall) == -1)
>  +                       return false;
>  +               else
>  +                       return true;
>  +       }
>  +
>  +       private void decorateOnClick(FacesContext facesContext, UIComponent 
> child,
>  +                       PDFExport pdfExport) {
>  +               String jsCall = getJSCall(facesContext, pdfExport);
>  +               String onclickEvent = (String) 
> child.getAttributes().get("onclick");
>  +               if (onclickEvent == null)
>  +                       child.getAttributes().put("onclick", jsCall);
>  +               else
>  +                       child.getAttributes().put("onclick", onclickEvent + 
> ";" + jsCall);
>  +       }
>  +
>  +       private String getJSCall(FacesContext facesContext, PDFExport 
> pdfExport) {
>  +               String viewId = StringUtils.split(facesContext.getViewRoot()
>  +                               .getViewId(), "\\.")[0];
>  +               return "window.open('"
>  +                               + 
> facesContext.getApplication().getViewHandler().getActionURL(
>  +                                               facesContext, viewId) + "?"
>  +                               + PDFExportConstants.PDF_EXPORT_TABLE_ID + 
> "="
>  +                               + pdfExport.getFor() + "&"
>  +                               + PDFExportConstants.PDF_EXPORT_FILE_NAME + 
> "="
>  +                               + pdfExport.getFilename() + "');return 
> false;";
>  +       }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportRenderer.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,66 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.custom.pdfexport;
>  +
>  +import javax.faces.component.UIComponent;
>  +
>  +import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
>  +
>  +public class PDFExportTag extends UIComponentTagBase {
>  +
>  +       private String _for;
>  +       private String _filename;
>  +
>  +       public void release() {
>  +               super.release();
>  +               _for = null;
>  +               _filename = null;
>  +       }
>  +
>  +       protected void setProperties(UIComponent component) {
>  +               super.setProperties(component);
>  +
>  +               setStringProperty(component, "for", _for);
>  +               setStringProperty(component, "filename", _filename);
>  +       }
>  +
>  +       public String getComponentType() {
>  +               return PDFExport.COMPONENT_TYPE;
>  +       }
>  +
>  +       public String getRendererType() {
>  +               return "org.apache.myfaces.PDFExportRenderer";
>  +       }
>  +
>  +       public String getFor() {
>  +               return _for;
>  +       }
>  +
>  +       public void setFor(String aFor) {
>  +               _for = aFor;
>  +       }
>  +
>  +       public String getFilename() {
>  +               return _filename;
>  +       }
>  +
>  +       public void setFilename(String filename) {
>  +               this._filename = filename;
>  +       }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/PDFExportTag.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,24 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.custom.pdfexport.util;
>  +
>  +public interface PDFExportConstants {
>  +       public static String PDF_EXPORT_TABLE_ID  = "pdfExportTableId";
>  +       public static String PDF_EXPORT_FILE_NAME = "pdfExportFileName";
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/pdfexport/util/PDFExportConstants.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Modified: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java?rev=645018&r1=645017&r2=645018&view=diff
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
>  (original)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
>  Fri Apr  4 19:28:48 2008
>  @@ -19,16 +19,20 @@
>
>   package org.apache.myfaces.custom.util;
>
>  +import javax.faces.component.UIColumn;
>   import javax.faces.component.UIComponent;
>   import javax.faces.component.UIParameter;
>  +import javax.faces.component.html.HtmlDataTable;
>   import javax.faces.component.html.HtmlMessages;
>   import javax.faces.context.FacesContext;
>   import javax.faces.lifecycle.LifecycleFactory;
>   import javax.faces.webapp.FacesServlet;
>   import javax.servlet.ServletContext;
>
>  +import java.util.ArrayList;
>   import java.util.HashMap;
>   import java.util.Iterator;
>  +import java.util.List;
>   import java.util.Map;
>
>   /**
>  @@ -187,4 +191,22 @@
>                 return lifecycleId != null ? lifecycleId
>                                 : LifecycleFactory.DEFAULT_LIFECYCLE;
>         }
>  -}
>  \ No newline at end of file
>  +
>  +       /**
>  +        * This method is used for getting the columns of
>  +        * a specific HTMLDataTable.
>  +        * @param table
>  +        * @return the List of UIColumns
>  +        */
>  +       public static List getHTMLDataTableColumns(HtmlDataTable table) {
>  +               List columns = new ArrayList();
>  +
>  +               for (int i = 0; i < table.getChildCount(); i++) {
>  +                       UIComponent child = (UIComponent) 
> table.getChildren().get( i );
>  +                       if (child instanceof UIColumn) {
>  +                               columns.add( child );
>  +                       }
>  +               }
>  +               return columns;
>  +       }
>  +}
>
>  Modified: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=645018&r1=645017&r2=645018&view=diff
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
>  (original)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
>  Fri Apr  4 19:28:48 2008
>  @@ -250,6 +250,11 @@
>    </component>
>
>    <component>
>  +               <component-type>org.apache.myfaces.PDFExport</component-type>
>  +               
> <component-class>org.apache.myfaces.custom.pdfexport.PDFExport</component-class>
>  +  </component>
>  +
>  +  <component>
>         <component-type>org.apache.myfaces.FloatingPaneBase</component-type>
>         
> <component-class>org.apache.myfaces.custom.dojolayouts.FloatingPaneBase</component-class>
>    </component>
>  @@ -592,6 +597,12 @@
>         <renderer-type>org.apache.myfaces.ExcelExportRenderer</renderer-type>
>      
> <renderer-class>org.apache.myfaces.custom.excelexport.ExcelExportRenderer</renderer-class>
>    </renderer>
>  +
>  +  <renderer>
>  +       <component-family>org.apache.myfaces.Export</component-family>
>  +       <renderer-type>org.apache.myfaces.PDFExportRenderer</renderer-type>
>  +    
> <renderer-class>org.apache.myfaces.custom.pdfexport.PDFExportRenderer</renderer-class>
>  +  </renderer>
>
>    <renderer>
>       <component-family>javax.faces.Output</component-family>
>  @@ -656,6 +667,7 @@
>           
> <phase-listener>org.apache.myfaces.custom.redirectTracker.RedirectTrackerPhaseListener</phase-listener>
>           
> <phase-listener>org.apache.myfaces.custom.ppr.PPRPhaseListener</phase-listener>
>           
> <phase-listener>org.apache.myfaces.custom.excelexport.ExcelExportPhaseListener</phase-listener>
>  +         
> <phase-listener>org.apache.myfaces.custom.pdfexport.PDFExportPhaseListener</phase-listener>
>    </lifecycle>
>
>    <application>
>
>  Modified: 
> myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=645018&r1=645017&r2=645018&view=diff
>  
> ==============================================================================
>  --- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld 
> (original)
>  +++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Fri 
> Apr  4 19:28:48 2008
>  @@ -1703,6 +1703,16 @@
>          &ui_component_attributes;
>          &excel_export_attributes;
>      </tag>
>  +
>  +    <tag>
>  +        <name>pdfExport</name>
>  +        
> <tag-class>org.apache.myfaces.custom.pdfexport.PDFExportTag</tag-class>
>  +        <body-content>JSP</body-content>
>  +        <description>Export datatable contents to a pdf file
>  +        </description>
>  +        &ui_component_attributes;
>  +        &excel_export_attributes;
>  +    </tag>
>
>         <tag>
>                 <name>floatingPane</name>
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,52 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.examples.pdfexport;
>  +
>  +import java.io.Serializable;
>  +import java.util.ArrayList;
>  +import java.util.List;
>  +
>  +
>  +public class PDFExportBean implements Serializable {
>  +
>  +       private List carsList;
>  +
>  +       public List getCarsList() {
>  +               if( carsList == null)
>  +                       carsList = createCarsList();
>  +               return carsList;
>  +       }
>  +
>  +       public void setCarsList(List carsList) {
>  +               this.carsList = carsList;
>  +       }
>  +
>  +       private List createCarsList() {
>  +               List list  = new ArrayList();
>  +               list.add( new SimpleCar(0, "typeA", "blue"));
>  +               list.add( new SimpleCar(1, "typeB", "red"));
>  +               list.add( new SimpleCar(2, "typeC", "orange"));
>  +               list.add( new SimpleCar(3, "typeD", "gray"));
>  +               list.add( new SimpleCar(4, "typeE", "white"));
>  +               list.add( new SimpleCar(5, "typeF", "black"));
>  +               list.add( new SimpleCar(6, "typeG", "yellow"));
>  +               list.add( new SimpleCar(6, "typeH", "purple"));
>  +               return list;
>  +       }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/PDFExportBean.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Added: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java?rev=645018&view=auto
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>  (added)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>  Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,70 @@
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +package org.apache.myfaces.examples.pdfexport;
>  +
>  +import java.io.Serializable;
>  +
>  +public class SimpleCar
>  +        implements Serializable
>  +{
>  +    /**
>  +     * serial id for serialisation versioning
>  +     */
>  +    private static final long serialVersionUID = 1L;
>  +    private int _id;
>  +    private String _type;
>  +    private String _color;
>  +
>  +    public SimpleCar(int id, String type, String color)
>  +    {
>  +        _id = id;
>  +        _type = type;
>  +        _color = color;
>  +    }
>  +
>  +    public int getId()
>  +    {
>  +        return _id;
>  +    }
>  +
>  +    public void setId(int id)
>  +    {
>  +        _id = id;
>  +    }
>  +
>  +    public String getType()
>  +    {
>  +        return _type;
>  +    }
>  +
>  +    public void setType(String type)
>  +    {
>  +        _type = type;
>  +    }
>  +
>  +    public String getColor()
>  +    {
>  +        return _color;
>  +    }
>  +
>  +    public void setColor(String color)
>  +    {
>  +        _color = color;
>  +    }
>  +}
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/pdfexport/SimpleCar.java
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>  Modified: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml?rev=645018&r1=645017&r2=645018&view=diff
>  
> ==============================================================================
>  --- 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
>  (original)
>  +++ 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
>  Fri Apr  4 19:28:48 2008
>  @@ -495,6 +495,12 @@
>         
> <managed-bean-class>org.apache.myfaces.examples.excelexport.ExcelExportBean</managed-bean-class>
>         <managed-bean-scope>request</managed-bean-scope>
>      </managed-bean>
>  +
>  +    <managed-bean>
>  +       <managed-bean-name>pdfExportBean</managed-bean-name>
>  +       
> <managed-bean-class>org.apache.myfaces.examples.pdfexport.PDFExportBean</managed-bean-class>
>  +       <managed-bean-scope>request</managed-bean-scope>
>  +    </managed-bean>
>
>      <!-- XMLTemplate -->
>      <managed-bean>
>
>  Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=645018&r1=645017&r2=645018&view=diff
>  
> ==============================================================================
>  --- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp 
> (original)
>  +++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Fri Apr 
>  4 19:28:48 2008
>  @@ -108,6 +108,7 @@
>                 <h:outputLink value="autoUpdateDataTable.jsf" 
> ><f:verbatim>Automatically updated dataTable per 
> AJAX</f:verbatim></h:outputLink>
>                 <h:outputLink 
> value="selectOneRow.jsf"><f:verbatim>selectOneRow - a DataTable 
> Enhancement</f:verbatim></h:outputLink>
>                 <h:outputLink value="excelExport.jsf"><f:verbatim>ExcelExport 
> - Export datatable contents as an excel file</f:verbatim></h:outputLink>
>  +               <h:outputLink value="pdfExport.jsf"><f:verbatim>PDFExport - 
> Export datatable contents as a PDF file</f:verbatim></h:outputLink>
>              </h:panelGrid>
>
>              <h:outputText value="Selection Lists"/>
>
>  Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp
>  URL: 
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp?rev=645018&view=auto
>  
> ==============================================================================
>  --- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp 
> (added)
>  +++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp 
> Fri Apr  4 19:28:48 2008
>  @@ -0,0 +1,86 @@
>  +<%@ page session="false" contentType="text/html;charset=utf-8"%>
>  +<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
>  +<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
>  +<%@ taglib uri="http://myfaces.apache.org/tomahawk"; prefix="t"%>
>  +<%@ taglib uri="http://myfaces.apache.org/sandbox"; prefix="s"%>
>  +<html>
>  +
>  +<!--
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF licenses this file
>  + * to you under the Apache License, Version 2.0 (the
>  + * "License"); you may not use this file except in compliance
>  + * with the License.  You may obtain a copy of the License at
>  + *
>  + *   http://www.apache.org/licenses/LICENSE-2.0
>  + *
>  + * Unless required by applicable law or agreed to in writing,
>  + * software distributed under the License is distributed on an
>  + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  + * KIND, either express or implied.  See the License for the
>  + * specific language governing permissions and limitations
>  + * under the License.
>  + */
>  +//-->
>  +
>  +<[EMAIL PROTECTED] file="inc/head.inc" %>
>  +
>  +<body>
>  +
>  +<f:view>
>  +
>  +    <h:form>
>  +       <p>This component allows to export the datatable contents to a pdf 
> file.</p>
>  +               <p>Note: Currently the component does not support client 
> side state saving.</p>
>  +
>  +               <br>
>  +
>  +               <t:dataTable id="tbl_cars"
>  +                styleClass="scrollerTable"
>  +                headerClass="standardTable_Header"
>  +                footerClass="standardTable_Header"
>  +                rowClasses="standardTable_Row1,standardTable_Row2"
>  +                
> columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
>  +                var="car"
>  +                value="#{pdfExportBean.carsList}"
>  +                preserveDataModel="false"
>  +           >
>  +           <h:column>
>  +               <f:facet name="header">
>  +                   <h:outputText value="Id" />
>  +               </f:facet>
>  +               <h:outputText value="#{car.id}" />
>  +           </h:column>
>  +
>  +           <h:column>
>  +               <f:facet name="header">
>  +                  <h:outputText value="Type" />
>  +               </f:facet>
>  +               <h:outputText value="#{car.type}" />
>  +           </h:column>
>  +
>  +           <h:column>
>  +               <f:facet name="header">
>  +                  <h:outputText value="Color" />
>  +               </f:facet>
>  +               <h:outputText value="#{car.color}" />
>  +           </h:column>
>  +
>  +        </t:dataTable>
>  +
>  +               <br>
>  +
>  +               <s:pdfExport for="tbl_cars">
>  +                       <h:commandButton action="" value="Export as PDF"/>
>  +               </s:pdfExport>
>  +    </h:form>
>  +</f:view>
>  +
>  +<[EMAIL PROTECTED] file="inc/page_footer.jsp" %>
>  +
>  +</body>
>  +
>  +</html>
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp
>  
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Propchange: 
> myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pdfExport.jsp
>  
> ------------------------------------------------------------------------------
>     svn:keywords = Date Author Id Revision HeadURL
>
>
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Reply via email to