svn commit: r1806238 - in /ofbiz/ofbiz-plugins/trunk: birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java

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

svn commit: r1806238 - in /ofbiz/ofbiz-plugins/trunk: birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java

nmalin
Author: nmalin
Date: Fri Aug 25 21:25:50 2017
New Revision: 1806238

URL: http://svn.apache.org/viewvc?rev=1806238&view=rev
Log:
Fixed: Correct library ftl call to render the email body (OFBIZ-9138 Create a common theme)
add possibility to call the ThemeFactory.resolveTheme() with empty request if the visualTheme normaly present on the service context isn't found, so we return the default theme define in general.properties
Thanks to Jacques for raise this problem

Modified:
    ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java
    ofbiz/ofbiz-plugins/trunk/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java

Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java?rev=1806238&r1=1806237&r2=1806238&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java (original)
+++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java Fri Aug 25 21:25:50 2017
@@ -50,8 +50,10 @@ import org.apache.ofbiz.service.Dispatch
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.ServiceUtil;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer;
 import org.eclipse.birt.report.engine.api.EngineException;
 import org.eclipse.birt.report.engine.api.IReportEngine;
@@ -88,6 +90,8 @@ public class BirtEmailServices {
         Map<String, Object> birtParameters = UtilGenerics.cast(serviceContext.remove(BirtWorker.getBirtParameters()));
         String birtImageDirectory = (String) serviceContext.remove(BirtWorker.getBirtImageDirectory());
         String birtContentType = (String) serviceContext.remove(BirtWorker.getBirtContentType());
+        VisualTheme visualTheme = (VisualTheme) context.get("visualTheme");
+        if (visualTheme == null) visualTheme = ThemeFactory.resolveVisualTheme(null);
         if (bodyParameters == null) {
             bodyParameters = MapStack.create();
         }
@@ -111,8 +115,7 @@ public class BirtEmailServices {
         screenContext.put("locale", locale);
         ScreenStringRenderer screenStringRenderer = null;
         try {
-            screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", delegator),
-                    EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", delegator));
+            screenStringRenderer = new MacroScreenRenderer("screen", visualTheme.getModelTheme().getScreenRendererLocation("screen"));
         } catch (TemplateException e) {
             String errMsg =  UtilProperties.getMessage(resource, "BirtErrorRenderingScreenForEmail", UtilMisc.toMap("errorString", e.toString()), locale);
             Debug.logError(e, errMsg, module);

Modified: ofbiz/ofbiz-plugins/trunk/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java?rev=1806238&r1=1806237&r2=1806238&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java (original)
+++ ofbiz/ofbiz-plugins/trunk/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java Fri Aug 25 21:25:50 2017
@@ -52,8 +52,10 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.service.DispatchContext;
 import org.apache.ofbiz.service.ServiceUtil;
 import org.apache.ofbiz.webapp.view.ApacheFopWorker;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer;
 import org.xml.sax.SAXException;
 
@@ -64,9 +66,11 @@ public class ExamplePrintServices {
     public static final String resource = "ExampleUiLabels";
 
     public static Map<String, Object> printReportPdf(DispatchContext dctx, Map<String, ? extends Object> context) {
-     Locale locale = (Locale)context.get("locale");
+        Locale locale = (Locale)context.get("locale");
         String screenLocation = "component://example/widget/example/ExampleReportScreens.xml";
         String reportScreenName = "ExampleReport";
+        VisualTheme visualTheme = (VisualTheme) context.get("visualTheme");
+        if (visualTheme == null) visualTheme = ThemeFactory.resolveVisualTheme(null);
         Map<String, Object> workContext = new HashMap<String, Object>();
         workContext.putAll(context);
 
@@ -74,8 +78,7 @@ public class ExamplePrintServices {
         Writer reportWriter = new StringWriter();
         ScreenStringRenderer screenStringRenderer = null;
         try {
-            screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", dctx.getDelegator()),
-                    EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", dctx.getDelegator()));
+            screenStringRenderer = new MacroScreenRenderer("screen", visualTheme.getModelTheme().getScreenRendererLocation("screen"));
         } catch (TemplateException e) {
             String errMsg = UtilProperties.getMessage(resource, "ExampleGeneralErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale);
             Debug.logError(e, errMsg, module);