svn commit: r519268 - in /ofbiz/trunk: applications/accounting/webapp/accounting/WEB-INF/ applications/content/webapp/content/WEB-INF/ applications/manufacturing/webapp/manufacturing/WEB-INF/ applications/marketing/webapp/marketing/WEB-INF/ application...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r519268 - in /ofbiz/trunk: applications/accounting/webapp/accounting/WEB-INF/ applications/content/webapp/content/WEB-INF/ applications/manufacturing/webapp/manufacturing/WEB-INF/ applications/marketing/webapp/marketing/WEB-INF/ application...

jacopoc
Author: jacopoc
Date: Sat Mar 17 02:17:54 2007
New Revision: 519268

URL: http://svn.apache.org/viewvc?view=rev&rev=519268
Log:
Enabled support to 'screenfop' view definitions for several output types supported by FOP; they are defined using the content-type attribute in the controller's view definition (application/pdf is the default)); try for example:

application/postscript
application/x-pcl
...
This is the first step toward providing print support for laser/barcode printers.
The change is backward compatible with all the existing view definitions, however I had to update all the controller xml files because I've renamed the view handler class name from ScreenFopPdfViewHandler to ScreenFopViewHandler, to better describe its role in the framework.
OFBIZ-823

Added:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java
      - copied, changed from r518934, ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopPdfViewHandler.java
Removed:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopPdfViewHandler.java
Modified:
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml
    ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml
    ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
    ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/controller.xml

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -35,7 +35,7 @@
     <!-- view handlers -->
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="screenxml" type="view" class="org.ofbiz.widget.screen.ScreenXmlViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
         

Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -33,7 +33,7 @@
     <handler name="bsf" type="request" class="org.ofbiz.webapp.event.BsfEventHandler"/>
 
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="simplecontent" type="view" class="org.ofbiz.content.view.SimpleContentViewHandler"/>
 
     <preprocessor>

Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -34,7 +34,7 @@
 
     <!-- view handlers -->
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
     
@@ -772,7 +772,7 @@
     <view-map name="WorkWithShipmentPlans" page="component://manufacturing/widget/manufacturing/JobshopScreens.xml#WorkWithShipmentPlans" type="screen"/>
     
     <!-- Report view mappings -->
-    <view-map name="ShipmentPlanStockReport" type="screenfop" page="component://manufacturing/widget/manufacturing/ReportScreens.xml#ShipmentPlanStockReport" content-type="application/pdf" encoding="none"/>    
+    <view-map name="ShipmentPlanStockReport" type="screenfop" page="component://manufacturing/widget/manufacturing/ReportScreens.xml#ShipmentPlanStockReport" content-type="application/pdf" encoding="none"/>
     <view-map name="ShipmentLabel" type="screenfop" page="component://manufacturing/widget/manufacturing/ReportScreens.xml#ShipmentLabel" content-type="application/pdf" encoding="none"/>
     <view-map name="ShipmentWorkEffortTasks" type="screenfop" page="component://manufacturing/widget/manufacturing/ReportScreens.xml#ShipmentWorkEffortTasks" content-type="application/pdf" encoding="none"/>
     <view-map name="CuttingListReport" type="screenfop" page="component://manufacturing/widget/manufacturing/ReportScreens.xml#CuttingListReport" content-type="application/pdf" encoding="none"/>

Modified: ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/marketing/webapp/marketing/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -30,7 +30,7 @@
     <handler name="simple" type="request" class="org.ofbiz.webapp.event.SimpleEventHandler"/>
     
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
     

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -34,7 +34,7 @@
 
     <!-- view handlers -->
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
 

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -32,7 +32,7 @@
     <handler name="bsf" type="request" class="org.ofbiz.webapp.event.BsfEventHandler"/>
 
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
 

Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -33,7 +33,7 @@
 
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="screenxml" type="view" class="org.ofbiz.widget.screen.ScreenXmlViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
 

Modified: ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -32,7 +32,7 @@
 
     <!-- view handlers -->
     <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
     <handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
     <handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
     

Copied: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java (from r518934, ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopPdfViewHandler.java)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java?view=diff&rev=519268&p1=ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopPdfViewHandler.java&r1=518934&p2=ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java&r2=519268
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopPdfViewHandler.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java Sat Mar 17 02:17:54 2007
@@ -32,22 +32,27 @@
 import org.apache.fop.apps.FOPException;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.webapp.view.ViewHandlerException;
 import org.ofbiz.webapp.view.ApacheFopFactory;
 import org.ofbiz.widget.fo.FoFormRenderer;
 
 /**
- * Uses XSL-FO formatted templates to generate PDF views
+ * Uses XSL-FO formatted templates to generate PDF, PCL, POSTSCRIPT etc.  views
  * This handler will use JPublish to generate the XSL-FO
  */
-public class ScreenFopPdfViewHandler extends ScreenWidgetViewHandler {
-    public static final String module = ScreenFopPdfViewHandler.class.getName();
+public class ScreenFopViewHandler extends ScreenWidgetViewHandler {
+    public static final String module = ScreenFopViewHandler.class.getName();
 
     /**
      * @see org.ofbiz.content.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      */
     public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
 
+        if (UtilValidate.isEmpty(contentType)) {
+            contentType = "application/pdf";
+        }
+        
         // render and obtain the XSL-FO
         Writer writer = new StringWriter();
 
@@ -69,10 +74,10 @@
         TransformerFactory transFactory = TransformerFactory.newInstance();
 
         try {
-            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
+            Fop fop = fopFactory.newFop(contentType, out);
             Transformer transformer = transFactory.newTransformer();
 
-            // set the input source (XSL-FO) and generate the PDF
+            // set the input source (XSL-FO) and generate the output stream of contentType
             Reader reader = new StringReader(writer.toString());
             Source src = new StreamSource(reader);
 
@@ -84,21 +89,21 @@
                 fw.close();
             } catch (IOException e) {
                 throw new ViewHandlerException("Unable write to browser OutputStream", e);            
-            }                            
+            }
             */
-            
+
             // Get handler that is used in the generation process
             Result res = new SAXResult(fop.getDefaultHandler());
 
             try {
-                // Transform the FOP XML source into a PDF, hopefully...
+                // Transform the FOP XML source
                 transformer.transform(src, res);
 
                 // We don't want to cache the images that get loaded by the FOP engine
                 fopFactory.getImageFactory().clearCaches();
 
                 // set the content type and length
-                response.setContentType(MimeConstants.MIME_PDF);
+                response.setContentType(contentType);
                 response.setContentLength(out.size());
 
                 // write to the browser
@@ -111,7 +116,7 @@
 
             } catch (TransformerException e) {
                 Debug.logError("FOP transform failed:" + e, module );
-                throw new ViewHandlerException("Unable to transform FO to PDF", e);
+                throw new ViewHandlerException("Unable to transform FO to " + contentType, e);
             }
 
         } catch (TransformerConfigurationException e) {

Modified: ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/controller.xml?view=diff&rev=519268&r1=519267&r2=519268
==============================================================================
--- ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/assetmaint/webapp/assetmaint/WEB-INF/controller.xml Sat Mar 17 02:17:54 2007
@@ -27,7 +27,7 @@
     <description>Asset Maintenance Component Site Configuration File</description>
     <errorpage>/error/error.jsp</errorpage>
 
-    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopPdfViewHandler"/>
+    <handler name="screenfop" type="view" class="org.ofbiz.widget.screen.ScreenFopViewHandler"/>
 
     <request-map uri="main">
         <security https="true" auth="true"/>