--- C:/ofbiz-10.04.03/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java	Thu Oct 25 21:13:39 2012
+++ C:/gnuwin32/bin/JasperReportsPdfViewHandler.java	Tue Nov 06 23:17:47 2012
@@ -16,40 +16,48 @@
  * specific language governing permissions and limitations
  * under the License.
  *******************************************************************************/
 package org.ofbiz.webapp.view;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import net.sf.jasperreports.engine.JRDataSource;
 import net.sf.jasperreports.engine.JREmptyDataSource;
 import net.sf.jasperreports.engine.JasperCompileManager;
 import net.sf.jasperreports.engine.JasperExportManager;
 import net.sf.jasperreports.engine.JasperFillManager;
 import net.sf.jasperreports.engine.JasperPrint;
 import net.sf.jasperreports.engine.JasperReport;
 
+import org.apache.tools.ant.types.resources.selectors.InstanceOf;
+import org.ofbiz.base.location.FlexibleLocation;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.webapp.control.ContextFilter;
 import org.ofbiz.webapp.view.AbstractViewHandler;
+import org.ofbiz.webapp.view.ViewHandlerException;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.jdbc.ConnectionFactory;
 
+import com.sun.org.apache.xpath.internal.operations.And;
 /**
  * Handles JasperReports PDF view rendering
  */
-public class JasperReportsPdfViewHandler extends AbstractViewHandler {
+public class JasperReportsPdfViewHandler extends AbstractViewHandler /*implements ViewHandler*/{
 
     public static final String module = JasperReportsPdfViewHandler.class.getName();
 
     protected ServletContext context;
     public static UtilCache jasperReportsCompiledCache = UtilCache.createUtilCache("webapp.JasperReportsCompiled");
 
     public void init(ServletContext context) throws ViewHandlerException {
@@ -65,43 +73,63 @@
         }
         if (UtilValidate.isEmpty(page)) {
             throw new ViewHandlerException("View page was null or empty, but must be specified");
         }
         if (UtilValidate.isEmpty(info)) {
             Debug.logInfo("View info string was null or empty, (optionally used to specify an Entity that is mapped to the Entity Engine datasource that the report will use).", module);
         }
+        URL reportFileUrl = null;
+        try {
+            reportFileUrl = FlexibleLocation.resolveLocation(page);
+        } catch (MalformedURLException e1) {
+            Debug.logError("Could not find Entity Data document in resource: " + page + "; error was: " + e1.toString(), module);
+        }
+
 
         // tell the ContextFilter we are forwarding
-        request.setAttribute(ContextFilter.FORWARDED_FROM_SERVLET, Boolean.valueOf(true));
+        request.setAttribute(ContextFilter.FORWARDED_FROM_SERVLET, new Boolean(true));
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         if (delegator == null) {
             throw new ViewHandlerException("The delegator object was null, how did that happen?");
         }
 
         try {
             JasperReport report = (JasperReport) jasperReportsCompiledCache.get(page);
             if (report == null) {
                 synchronized (this) {
                     report = (JasperReport) jasperReportsCompiledCache.get(page);
-                    if (report == null) {
-                        InputStream is = context.getResourceAsStream(page);
-                        report = JasperCompileManager.compileReport(is);
+                    if (report == null && reportFileUrl != null ) {
+                        report = JasperCompileManager.compileReport(reportFileUrl.openStream());
                         jasperReportsCompiledCache.put(page, report);
                     }
                 }
             }
 
             response.setContentType("application/pdf");
 
             Map parameters = (Map) request.getAttribute("jrParameters");
             if (parameters == null) {
                 parameters = UtilHttp.getParameterMap(request);
             }
+            //if local is not defined, define it
+            if (!parameters.containsKey("REPORT_LOCALE")){
+                parameters.put("REPORT_LOCALE", UtilHttp.getLocale(request));
+            }
 
-            JRDataSource jrDataSource = (JRDataSource) request.getAttribute("jrDataSource");
+            JRDataSource jrDataSource = null;
+            if (request.getAttribute("records") != null ){
+                Object records = request.getAttribute("records");
+                if( request.getAttribute("records") instanceof JRDataSource) {
+                    jrDataSource = (JRDataSource) records;
+                }
+            }
+            else{
+                jrDataSource = (JRDataSource) request.getAttribute("jrDataSource");
+            }
+            
             JasperPrint jp = null;
             if (jrDataSource == null) {
                 String datasourceName = delegator.getEntityHelperName(info);
                 if (UtilValidate.isNotEmpty(datasourceName)) {
                     Debug.logInfo("Filling report with connection from datasource: " + datasourceName, module);
                     jp = JasperFillManager.fillReport(report, parameters, ConnectionFactory.getConnection(datasourceName));
                 } else {
