details:   https://code.openbravo.com/erp/devel/pi/rev/c3112a8c4e22
changeset: 22778:c3112a8c4e22
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Thu Mar 27 13:07:49 2014 +0530
summary:   Fixes Issue 26095, related to issue 25053 : Record not refreshed 
after printing record

Added a new method printPagePopUpDownloadAndRefresh to enable refreshing the 
grid after printing the record.
Added a new argument 'forceRefresh' in renderJR method to force refresh the 
grid.

diffstat:

 src/org/openbravo/base/secureApp/HttpSecureAppServlet.java     |  43 ++++++++-
 src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.html |  49 ++++++++++
 src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.xml  |  16 +++
 3 files changed, 106 insertions(+), 2 deletions(-)

diffs (148 lines):

diff -r 8c3a6328b7d0 -r c3112a8c4e22 
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Wed Mar 
26 16:35:47 2014 +0000
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Thu Mar 
27 13:07:49 2014 +0530
@@ -1024,6 +1024,18 @@
     os.close();
   }
 
+  protected void printPagePopUpDownloadAndRefresh(ServletOutputStream os, 
String fileName)
+      throws IOException, ServletException {
+    if (log4j.isDebugEnabled())
+      log4j.debug("Output: PopUp Download");
+    String href = strDireccion + "/utility/DownloadReport.html?report=" + 
fileName;
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
+        
"org/openbravo/base/secureApp/PopUp_DownloadAndRefresh").createXmlDocument();
+    xmlDocument.setParameter("href", href);
+    os.println(xmlDocument.print());
+    os.close();
+  }
+
   private void printPageClosePopUpAndRefresh(HttpServletResponse response, 
VariablesSecureApp vars)
       throws IOException, ServletException {
     if (log4j.isDebugEnabled())
@@ -1195,6 +1207,20 @@
     }
   }
 
+  protected void renderJR(VariablesSecureApp variables, HttpServletResponse 
response,
+      String strReportName, String strFileName, String strOutputType,
+      HashMap<String, Object> designParameters, FieldProvider[] data,
+      Map<Object, Object> exportParameters, boolean forceRefresh) throws 
ServletException {
+    if (data != null) {
+      renderJR(variables, response, strReportName, strFileName, strOutputType, 
designParameters,
+          new JRFieldProviderDataSource(data, variables.getJavaDateFormat()), 
exportParameters,
+          forceRefresh);
+    } else {
+      renderJR(variables, response, strReportName, strFileName, strOutputType, 
designParameters,
+          (JRDataSource) null, exportParameters, forceRefresh);
+    }
+  }
+
   /**
    * Render a jrxml based report using a {@link ScrollableFieldProvider} as 
its datasource.
    * 
@@ -1214,6 +1240,14 @@
       String strReportName, String strFileName, String strOutputType,
       HashMap<String, Object> designParameters, JRDataSource data,
       Map<Object, Object> exportParameters) throws ServletException {
+    renderJR(variables, response, strReportName, strFileName, strOutputType, 
designParameters,
+        data, exportParameters, false);
+  }
+
+  protected void renderJR(VariablesSecureApp variables, HttpServletResponse 
response,
+      String strReportName, String strFileName, String strOutputType,
+      HashMap<String, Object> designParameters, JRDataSource data,
+      Map<Object, Object> exportParameters, boolean forceRefresh) throws 
ServletException {
     if (strReportName == null || strReportName.equals(""))
       strReportName = PrintJRData.getReportName(this, classInfo.id);
 
@@ -1337,8 +1371,13 @@
         response.setContentType("text/html;charset=UTF-8");
         response.setHeader("Content-disposition", "inline" + "; filename=" + 
strFileName + "-"
             + (reportId) + ".html");
-        printPagePopUpDownload(response.getOutputStream(), strFileName + "-" + 
(reportId) + "."
-            + strOutputType);
+        if (forceRefresh) {
+          printPagePopUpDownloadAndRefresh(response.getOutputStream(), 
strFileName + "-"
+              + (reportId) + "." + strOutputType);
+        } else {
+          printPagePopUpDownload(response.getOutputStream(), strFileName + "-" 
+ (reportId) + "."
+              + strOutputType);
+        }
       } else {
         throw new ServletException("Output format no supported");
       }
diff -r 8c3a6328b7d0 -r c3112a8c4e22 
src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.html
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.html    Thu Mar 
27 13:07:49 2014 +0530
@@ -0,0 +1,49 @@
+<!--
+ 
************************************************************************************
+ * Copyright (C) 2014 Openbravo S.L.U.
+ * Licensed under the Apache Software License version 2.0
+ * 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.
+ 
************************************************************************************
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title></title>
+<link rel="shortcut icon" href="../../../../../web/images/favicon.ico" 
type="image/x-icon" />
+<script language="JavaScript" src="../../../../../web/js/utils.js" 
type="text/javascript"></script>
+<script language="javascript">
+    function onLoadDo(url) {
+      if (getFrame('LayoutMDI')) {
+        getFrame('LayoutMDI').document.getElementById('background_target').src 
= url;
+      } else if (typeof top.opener.parent.appFrame !== 'undefined') {
+        top.opener.parent.appFrame.document.location.href = url;
+      }
+      else {
+        top.opener.parent.document.location.href = url;
+      }
+      var buttonRefresh;
+      if (opener && opener.parent && opener.parent.appFrame && 
opener.parent.appFrame.document.getElementById('buttonRefresh')) {
+        buttonRefresh = 
opener.parent.appFrame.document.getElementById('buttonRefresh');
+      } else if (getFrame('LayoutMDI') && 
getFrame('LayoutMDI').OB.MainView.TabSet.getSelectedTab().pane.getClassName() 
=== 'OBClassicWindow') {
+        buttonRefresh = 
getFrame('LayoutMDI').OB.MainView.TabSet.getSelectedTab().pane.getAppFrameWindow().document.getElementById('buttonRefresh');
+      }
+      if (buttonRefresh) {
+        buttonRefresh.onclick();
+      } else if (getFrame('LayoutMDI') && 
getFrame('LayoutMDI').OB.MainView.TabSet.getSelectedTab().pane.view) {
+        var theView = 
getFrame('LayoutMDI').OB.MainView.TabSet.getSelectedTab().pane.view;
+        theView.refresh(function(){
+            theView.getTabMessage();
+            theView.toolBar.refreshCustomButtons();
+        });
+      }
+      closePage();
+    }
+  </script>
+</head>
+<body onload="onLoadDo('xx');" style="background-color: #505050;" 
id="paramHref">
+</body>
+</html>
\ No newline at end of file
diff -r 8c3a6328b7d0 -r c3112a8c4e22 
src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/secureApp/PopUp_DownloadAndRefresh.xml     Thu Mar 
27 13:07:49 2014 +0530
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 
************************************************************************************
+ * Copyright (C) 2014 Openbravo S.L.U.
+ * Licensed under the Apache Software License version 2.0
+ * 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.
+ 
************************************************************************************
+-->
+<REPORT>
+       <TEMPLATE file="PopUp_DownloadAndRefresh.html"/>
+       <PARAMETER id="paramHref" name="href" attribute="onload" replace="xx"/>
+</REPORT>

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to