Source Code Cross Referenced for SpreadsheetUtil.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » jsf » spreadsheet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.jsf.spreadsheet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /**********************************************************************************
02:         *
03:         * $Id: SpreadsheetUtil.java 22226 2007-03-06 17:42:53Z ray@media.berkeley.edu $
04:         *
05:         ***********************************************************************************
06:         *
07:         * Copyright (c) 2007 The Regents of the University of California
08:         *
09:         * Licensed under the Educational Community License, Version 1.0 (the "License");
10:         * you may not use this file except in compliance with the License.
11:         * You may obtain a copy of the License at
12:         *
13:         *      http://www.opensource.org/licenses/ecl1.php
14:         *
15:         * Unless required by applicable law or agreed to in writing, software
16:         * distributed under the License is distributed on an "AS IS" BASIS,
17:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18:         * See the License for the specific language governing permissions and
19:         * limitations under the License.
20:         *
21:         **********************************************************************************/package org.sakaiproject.jsf.spreadsheet;
22:
23:        import java.util.List;
24:
25:        import javax.faces.context.FacesContext;
26:        import javax.servlet.http.HttpServletResponse;
27:
28:        /**
29:         *
30:         */
31:        public class SpreadsheetUtil {
32:            /**
33:             * Download a spreadsheet file containing the input list of data.
34:             * 
35:             * @param spreadsheetData a list of rows, beginning with a header row, each being a list
36:             * @param fileName not including the file extension, since that's format-dependent
37:             */
38:            public static void downloadSpreadsheetData(
39:                    List<List<Object>> spreadsheetData, String fileName,
40:                    SpreadsheetDataFileWriter fileWriter) {
41:                FacesContext faces = FacesContext.getCurrentInstance();
42:                HttpServletResponse response = (HttpServletResponse) faces
43:                        .getExternalContext().getResponse();
44:                protectAgainstInstantDeletion(response);
45:                fileWriter.writeDataToResponse(spreadsheetData, fileName,
46:                        response);
47:                faces.responseComplete();
48:            }
49:
50:            /**
51:             * Try to head off a problem with downloading files from a secure HTTPS
52:             * connection to Internet Explorer.
53:             *
54:             * When IE sees it's talking to a secure server, it decides to treat all hints
55:             * or instructions about caching as strictly as possible. Immediately upon
56:             * finishing the download, it throws the data away.
57:             *
58:             * Unfortunately, the way IE sends a downloaded file on to a helper
59:             * application is to use the cached copy. Having just deleted the file,
60:             * it naturally isn't able to find it in the cache. Whereupon it delivers
61:             * a very misleading error message like:
62:             * "Internet Explorer cannot download roster from sakai.yoursite.edu.
63:             * Internet Explorer was not able to open this Internet site. The requested
64:             * site is either unavailable or cannot be found. Please try again later."
65:             *
66:             * There are several ways to turn caching off, and so to be safe we use
67:             * several ways to turn it back on again.
68:             *
69:             * This current workaround should let IE users save the files to disk.
70:             * Unfortunately, errors may still occur if a user attempts to open the
71:             * file directly in a helper application from a secure web server.
72:             *
73:             * TODO Keep checking on the status of this.
74:             */
75:            private static void protectAgainstInstantDeletion(
76:                    HttpServletResponse response) {
77:                response.reset(); // Eliminate the added-on stuff
78:                response.setHeader("Pragma", "public"); // Override old-style cache control
79:                response
80:                        .setHeader("Cache-Control",
81:                                "public, must-revalidate, post-check=0, pre-check=0, max-age=0"); // New-style
82:            }
83:
84:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.