[jasper-library-upgrade] Added cast to retrieve parameters correctly
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 21 May 2015 11:11:36 +0200
changeset 26757 a1fbec4aff43
parent 26756 70d08d47878a
child 26758 6f7b69ae53ca
[jasper-library-upgrade] Added cast to retrieve parameters correctly
modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java	Thu May 21 10:04:24 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java	Thu May 21 11:11:36 2015 +0200
@@ -659,8 +659,13 @@
       Map<Object, Object> params) {
     SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
     for (Entry<Object, Object> pair : params.entrySet()) {
-      String parameter = ((net.sf.jasperreports.engine.JRExporterParameter) pair.getKey())
-          .toString();
+      Object key = pair.getKey();
+      String parameter;
+      if (key instanceof net.sf.jasperreports.engine.JRExporterParameter) {
+        parameter = ((net.sf.jasperreports.engine.JRExporterParameter) key).toString();
+      } else {
+        parameter = "";
+      }
       if (parameter.equals("Is One Page per Sheet")) {
         configuration.setOnePagePerSheet((Boolean) pair.getValue());
       } else if (parameter.equals("Is Remove Empty Space Between Rows")) {
@@ -717,8 +722,15 @@
     // This is needed just in case the params map only contains the Images URI parameter
     configuration.setSizeUnit(HtmlSizeUnitEnum.POINT);
     for (Entry<Object, Object> pair : params.entrySet()) {
-      String parameter = ((net.sf.jasperreports.engine.JRExporterParameter) pair.getKey())
-          .toString();
+      Object key = pair.getKey();
+      String parameter;
+      if (key instanceof net.sf.jasperreports.engine.JRExporterParameter) {
+        parameter = ((net.sf.jasperreports.engine.JRExporterParameter) key).toString();
+      } else if (key instanceof String) {
+        parameter = (String) key;
+      } else {
+        parameter = "";
+      }
       if (parameter.equals("Images URI")) {
         exporterOutput.setImageHandler(new WebHtmlResourceHandler((String) pair.getValue()));
       } else if (parameter.equals("Is Remove Empty Space Between Rows")) {