svn commit: r1806134 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ common/src/main/java/org/apache/ofbiz/common/ common/src/main/java/org/apache/ofbiz/common/scripting/ service/src/main/java/org/apache/ofbi...

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

svn commit: r1806134 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ common/src/main/java/org/apache/ofbiz/common/ common/src/main/java/org/apache/ofbiz/common/scripting/ service/src/main/java/org/apache/ofbi...

nmalin
Author: nmalin
Date: Fri Aug 25 08:18:35 2017
New Revision: 1806134

URL: http://svn.apache.org/viewvc?rev=1806134&view=rev
Log:
Implemented: Continue the common-theme upload (OFBIZ-9138 Create a common theme)
Four step load the visualTheme in user session, freemarker, screen, groovy and service context
Add util to resolve easily a visualTheme

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
    ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java
    ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ContextHelper.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java Fri Aug 25 08:18:35 2017
@@ -56,6 +56,7 @@ import org.apache.http.conn.ssl.TrustSel
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.ssl.SSLContexts;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.PatternMatcher;
@@ -78,6 +79,7 @@ public final class UtilHttp {
     private static final int COMPOSITE_DELIMITER_LENGTH = COMPOSITE_DELIMITER.length();
 
     private static final String SESSION_KEY_TIMEZONE = "timeZone";
+    private static final String SESSION_KEY_THEME = "visualTheme";
 
     private UtilHttp () {}
 
@@ -726,6 +728,21 @@ public final class UtilHttp {
     }
 
     /**
+     * Return the VisualTheme object from the user session
+     * @param request
+     * @return
+     */
+    public static VisualTheme getVisualTheme(HttpServletRequest request) {
+        return (VisualTheme) request.getSession().getAttribute(SESSION_KEY_THEME);
+    }
+    public static void setVisualTheme(HttpServletRequest request, VisualTheme visualTheme) {
+        setVisualTheme(request.getSession(), visualTheme);
+    }
+    public static void setVisualTheme(HttpSession session, VisualTheme visualTheme) {
+        session.setAttribute(SESSION_KEY_THEME, visualTheme);
+    }
+
+    /**
      * Get the currency string from the session.
      * @param session HttpSession object to use for lookup
      * @return String The ISO currency code

Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/CommonEvents.java Fri Aug 25 08:18:35 2017
@@ -58,6 +58,8 @@ import org.apache.ofbiz.entity.GenericVa
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.entity.util.EntityUtilProperties;
 import org.apache.ofbiz.security.Security;
+import org.apache.ofbiz.widget.model.ThemeFactory;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 /**
  * Common Services
@@ -247,6 +249,18 @@ public class CommonEvents {
             }
         }
         return "success";
+    }
+
+    /** Simple event to set the user's per-session theme setting. */
+    public static String setSessionTheme(HttpServletRequest request, HttpServletResponse response) {
+        String visualThemeId = request.getParameter("userPrefValue");
+        if (UtilValidate.isNotEmpty(visualThemeId)) {
+            VisualTheme visualTheme = ThemeFactory.getVisualThemeFromId(visualThemeId);
+            if (visualTheme != null) {
+                UtilHttp.setVisualTheme(request, visualTheme);
+            }
+        }
+        return "success";
     }
 
     /** Simple event to set the users per-session currency uom value */

Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ContextHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ContextHelper.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ContextHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ContextHelper.java Fri Aug 25 08:18:35 2017
@@ -41,6 +41,7 @@ import org.apache.ofbiz.entity.GenericVa
 import org.apache.ofbiz.security.Security;
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ModelService;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 /**
  * A set of <code>ScriptContext</code> convenience methods for scripting engines.
@@ -135,6 +136,10 @@ public final class ContextHelper {
         return (Locale) this.context.getAttribute("locale");
     }
 
+    public VisualTheme getVisualTheme() {
+        return (VisualTheme) this.context.getAttribute("visualTheme");
+    }
+
     public Object getParameter(String key) {
         return getParameters().get(key);
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java Fri Aug 25 08:18:35 2017
@@ -59,6 +59,7 @@ public final class GroovyEngine extends
         newSet.add("dctx");
         newSet.add("dispatcher");
         newSet.add("delegator");
+        newSet.add("visualTheme");
         return Collections.unmodifiableSet(newSet);
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlServlet.java Fri Aug 25 08:18:35 2017
@@ -47,6 +47,7 @@ import org.apache.ofbiz.security.Securit
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.webapp.stats.ServerHitBin;
 import org.apache.ofbiz.webapp.stats.VisitHandler;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 import freemarker.ext.servlet.ServletContextHashModel;
 
@@ -178,6 +179,10 @@ public class ControlServlet extends Http
         }
         request.setAttribute("security", security);
 
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        if (visualTheme != null) {
+            UtilHttp.setVisualTheme(request, visualTheme);
+        }
         request.setAttribute("_REQUEST_HANDLER_", requestHandler);
         
         ServletContextHashModel ftlServletContext = new ServletContextHashModel(this, FreeMarkerWorker.getDefaultOfbizWrapper());

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java Fri Aug 25 08:18:35 2017
@@ -79,6 +79,7 @@ import org.apache.ofbiz.service.ModelSer
 import org.apache.ofbiz.service.ServiceUtil;
 import org.apache.ofbiz.webapp.WebAppUtil;
 import org.apache.ofbiz.webapp.stats.VisitHandler;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 
 /**
  * Common Workers
@@ -577,6 +578,10 @@ public class LoginWorker {
         }
         session.setAttribute("javaScriptEnabled", Boolean.valueOf("Y".equals(javaScriptEnabled)));
 
+        //init theme from user preference, clean the current visualTheme value in session and restart the resolution
+        UtilHttp.setVisualTheme(session, null);
+        UtilHttp.setVisualTheme(session, ThemeFactory.resolveVisualTheme(request));
+
         ModelEntity modelUserLogin = userLogin.getModelEntity();
         if (modelUserLogin.isField("partyId")) {
             // if partyId is a field, then we should have these relations defined

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java Fri Aug 25 08:18:35 2017
@@ -60,6 +60,7 @@ import org.apache.ofbiz.webapp.view.View
 import org.apache.ofbiz.webapp.view.ViewHandlerException;
 import org.apache.ofbiz.webapp.website.WebSiteProperties;
 import org.apache.ofbiz.webapp.website.WebSiteWorker;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 
 /**
  * RequestHandler - Request Processor Object
@@ -849,7 +850,10 @@ public class RequestHandler {
         if (UtilValidate.isNotEmpty(servletName) && servletName.length() > 1 || servletName.startsWith("/")) {
             servletName = servletName.substring(1);
         }
-        
+
+        if (UtilHttp.getVisualTheme(req) == null) {
+            UtilHttp.setVisualTheme(req.getSession(), ThemeFactory.resolveVisualTheme(req));
+        }
         if (Debug.infoOn()) Debug.logInfo("Rendering View [" + view + "]. " + showSessionId(req), module);
         if (view.startsWith(servletName + "/")) {
             view = view.substring(servletName.length() + 1);

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/ServiceEventHandler.java Fri Aug 25 08:18:35 2017
@@ -57,6 +57,7 @@ import org.apache.ofbiz.webapp.control.C
 import org.apache.ofbiz.webapp.control.ConfigXMLReader.Event;
 import org.apache.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
 import org.apache.ofbiz.webapp.control.ControlActivationEventListener;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 /**
  * ServiceEventHandler - Service Event Handler
@@ -108,6 +109,7 @@ public class ServiceEventHandler impleme
         // some needed info for when running the service
         Locale locale = UtilHttp.getLocale(request);
         TimeZone timeZone = UtilHttp.getTimeZone(request);
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
         HttpSession session = request.getSession();
         GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
 
@@ -245,6 +247,8 @@ public class ServiceEventHandler impleme
             if ("locale".equals(name)) continue;
             // don't include timeZone, that is also taken care of below
             if ("timeZone".equals(name)) continue;
+            // don't include theme, that is also taken care of below
+            if ("visualTheme".equals(name)) continue;
 
             Object value = null;
             if (UtilValidate.isNotEmpty(modelParam.stringMapPrefix)) {
@@ -332,6 +336,11 @@ public class ServiceEventHandler impleme
             serviceContext.put("timeZone", timeZone);
         }
 
+        // include the Theme object
+        if (visualTheme != null) {
+            serviceContext.put("visualTheme", visualTheme);
+        }
+
         // invoke the service
         Map<String, Object> result = null;
         try {

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java Fri Aug 25 08:18:35 2017
@@ -74,12 +74,34 @@ public class ThemeFactory {
     }
 
     /**
+     * Scann all Theme.xml definition to reload all VisualTheme oin cache
+     */
+    private static void pullModelThemesFromXmlToCache() {
+        String ofbizHome = System.getProperty("ofbiz.home");
+        try {
+            List<File> xmlThemes = FileUtil.findXmlFiles(ofbizHome, "themes", "theme", "widget-theme.xsd");
+            List<File> xmlPluginThemes = FileUtil.findXmlFiles(ofbizHome, "plugins", "theme", "widget-theme.xsd");
+            if (UtilValidate.isNotEmpty(xmlPluginThemes)) xmlThemes.addAll(xmlPluginThemes);
+            for (File xmlTheme : xmlThemes) {
+                ModelTheme modelTheme = getModelThemeFromLocation(xmlTheme.toURI().toURL().toString());
+                if (modelTheme != null) {
+                    for (String containsVisualThemeId : modelTheme.getVisualThemeIds()) {
+                        themeVisualThemeIdCache.put(containsVisualThemeId, modelTheme.getVisualTheme(containsVisualThemeId));
+                    }
+                }
+            }
+        } catch (IOException e) {
+            Debug.logError("Impossible to initialize models themes in cache throw: " + e, module);
+        }
+    }
+
+    /**
      * From a visualThemeId return the VisualTheme object corresponding in cache
      * If it's empty, reload the cache from all Theme definition
      * @param visualThemeId
      * @return
      */
-    private static VisualTheme getVisualThemeFromId(String visualThemeId) {
+    public static VisualTheme getVisualThemeFromId(String visualThemeId) {
         if (visualThemeId == null) return null;
         VisualTheme visualTheme = themeVisualThemeIdCache.get(visualThemeId);
         if (visualTheme == null) {
@@ -100,28 +122,6 @@ public class ThemeFactory {
     }
 
     /**
-     * Scann all Theme.xml definition to reload all VisualTheme oin cache
-     */
-    private static void pullModelThemesFromXmlToCache() {
-        String ofbizHome = System.getProperty("ofbiz.home");
-        try {
-            List<File> xmlThemes = FileUtil.findXmlFiles(ofbizHome, "themes", "theme", "widget-theme.xsd");
-            List<File> xmlPluginThemes = FileUtil.findXmlFiles(ofbizHome, "plugins", "theme", "widget-theme.xsd");
-            if (UtilValidate.isNotEmpty(xmlPluginThemes)) xmlThemes.addAll(xmlPluginThemes);
-            for (File xmlTheme : xmlThemes) {
-                ModelTheme modelTheme = getModelThemeFromLocation(xmlTheme.toURI().toURL().toString());
-                if (modelTheme != null) {
-                    for (String containsVisualThemeId : modelTheme.getVisualThemeIds()) {
-                        themeVisualThemeIdCache.put(containsVisualThemeId, modelTheme.getVisualTheme(containsVisualThemeId));
-                    }
-                }
-            }
-        } catch (IOException e) {
-            Debug.logError("Impossible to initialize models themes in cache throw: " + e, module);
-        }
-    }
-
-    /**
      * From a theme file location, resolve the modelTheme related from the cache.
      * If empty, load the modeTheme definition and put it in cache
      * @param resourceName

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java Fri Aug 25 08:18:35 2017
@@ -215,6 +215,9 @@ public class ScreenRenderer {
 
         // ========== setup values that are specific to OFBiz webapps
 
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        context.put("visualTheme", visualTheme);
+        context.put("modelTheme", visualTheme.getModelTheme());
         context.put("request", request);
         context.put("response", response);
         context.put("session", session);

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java Fri Aug 25 08:18:35 2017
@@ -37,6 +37,7 @@ import org.apache.fop.pdf.PDFEncryptionP
 import org.apache.fop.render.pdf.PDFEncryptionOption;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.UtilCodec;
+import org.apache.ofbiz.base.util.UtilHttp;
 import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.entity.Delegator;
@@ -44,9 +45,11 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.webapp.view.AbstractViewHandler;
 import org.apache.ofbiz.webapp.view.ApacheFopWorker;
 import org.apache.ofbiz.webapp.view.ViewHandlerException;
+import org.apache.ofbiz.widget.model.ModelTheme;
 import org.apache.ofbiz.widget.renderer.FormStringRenderer;
 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.MacroFormRenderer;
 import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer;
 
@@ -75,6 +78,9 @@ public class ScreenFopViewHandler extend
     public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
 
         Delegator delegator = (Delegator) request.getAttribute("delegator");
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        ModelTheme modelTheme = visualTheme.getModelTheme();
+
         // render and obtain the XSL-FO
         Writer writer = new StringWriter();
         try {

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Fri Aug 25 08:18:35 2017
@@ -85,11 +85,14 @@ import org.apache.ofbiz.widget.model.Mod
 import org.apache.ofbiz.widget.model.ModelFormFieldBuilder;
 import org.apache.ofbiz.widget.model.ModelScreenWidget;
 import org.apache.ofbiz.widget.model.ModelSingleForm;
+import org.apache.ofbiz.widget.model.ModelTheme;
 import org.apache.ofbiz.widget.model.ModelWidget;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 import org.apache.ofbiz.widget.renderer.FormRenderer;
 import org.apache.ofbiz.widget.renderer.FormStringRenderer;
 import org.apache.ofbiz.widget.renderer.Paginator;
 import org.apache.ofbiz.widget.renderer.UtilHelpText;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 import com.ibm.icu.util.Calendar;
 
@@ -111,6 +114,7 @@ public final class MacroFormRenderer imp
     private final HttpServletRequest request;
     private final HttpServletResponse response;
     private final boolean javaScriptEnabled;
+    private final VisualTheme visualTheme;
     private boolean renderPagination = true;
     private boolean widgetCommentsEnabled = false;
 
@@ -118,6 +122,7 @@ public final class MacroFormRenderer imp
         macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath);
         this.request = request;
         this.response = response;
+        this.visualTheme = ThemeFactory.resolveVisualTheme(request);
         ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
         this.rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
         this.javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request);
@@ -140,6 +145,7 @@ public final class MacroFormRenderer imp
     private void executeMacro(Appendable writer, String macro) throws IOException {
         try {
             Environment environment = getEnvironment(writer);
+            environment.setVariable("visualTheme", FreeMarkerWorker.autoWrap(visualTheme, environment));
             Reader templateReader = new StringReader(macro);
             Template template = new Template(new UID().toString(), templateReader, FreeMarkerWorker.getDefaultOfbizConfig());
             templateReader.close();
@@ -3067,6 +3073,8 @@ public final class MacroFormRenderer imp
         // get the parameterized pagination index and size fields
         int paginatorNumber = WidgetWorker.getPaginatorNumber(context);
         ModelForm modelForm = modelFormField.getModelForm();
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        ModelTheme modelTheme = visualTheme.getModelTheme();
         String viewIndexField = modelForm.getMultiPaginateIndexField(context);
         String viewSizeField = modelForm.getMultiPaginateSizeField(context);
         int viewIndex = Paginator.getViewIndex(modelForm, context);

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java Fri Aug 25 08:18:35 2017
@@ -45,7 +45,9 @@ import org.apache.ofbiz.widget.model.Mod
 import org.apache.ofbiz.widget.model.ModelMenuItem;
 import org.apache.ofbiz.widget.model.ModelMenuItem.MenuLink;
 import org.apache.ofbiz.widget.model.ModelWidget;
+import org.apache.ofbiz.widget.model.ThemeFactory;
 import org.apache.ofbiz.widget.renderer.MenuStringRenderer;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 
 import freemarker.core.Environment;
 import freemarker.template.Template;
@@ -59,11 +61,13 @@ public class MacroMenuRenderer implement
     private final Template macroLibrary;
     private final HttpServletRequest request;
     private final HttpServletResponse response;
+    private final VisualTheme visualTheme;
 
     public MacroMenuRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response) throws TemplateException, IOException {
         this.macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath);
         this.request = request;
         this.response = response;
+        this.visualTheme = ThemeFactory.resolveVisualTheme(request);
     }
 
     // Made this a separate method so it can be externalized and reused.
@@ -97,6 +101,7 @@ public class MacroMenuRenderer implement
 
     private void executeMacro(Appendable writer, String macro) throws IOException, TemplateException {
         Environment environment = getEnvironment(writer);
+        environment.setVariable("visualTheme", FreeMarkerWorker.autoWrap(visualTheme, environment));
         Reader templateReader = new StringReader(macro);
         macroCount++;
         String templateName = toString().concat("_") + macroCount;

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Fri Aug 25 08:18:35 2017
@@ -57,12 +57,14 @@ import org.apache.ofbiz.widget.model.Mod
 import org.apache.ofbiz.widget.model.ModelScreenWidget;
 import org.apache.ofbiz.widget.model.ModelScreenWidget.Column;
 import org.apache.ofbiz.widget.model.ModelScreenWidget.ColumnContainer;
+import org.apache.ofbiz.widget.model.ModelTheme;
 import org.apache.ofbiz.widget.model.ModelWidget;
 import org.apache.ofbiz.widget.model.ScreenFactory;
 import org.apache.ofbiz.widget.renderer.FormStringRenderer;
 import org.apache.ofbiz.widget.renderer.MenuStringRenderer;
 import org.apache.ofbiz.widget.renderer.Paginator;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 import org.xml.sax.SAXException;
 
 import freemarker.core.Environment;
@@ -223,7 +225,8 @@ public class MacroScreenRenderer impleme
     public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.ScreenLink link) throws IOException {
         HttpServletResponse response = (HttpServletResponse) context.get("response");
         HttpServletRequest request = (HttpServletRequest) context.get("request");
-
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        ModelTheme modelTheme = visualTheme.getModelTheme();
         String targetWindow = link.getTargetWindow(context);
         String target = link.getTarget(context);
 
@@ -584,6 +587,8 @@ public class MacroScreenRenderer impleme
     public void renderScreenletBegin(Appendable writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException {
         HttpServletRequest request = (HttpServletRequest) context.get("request");
         HttpServletResponse response = (HttpServletResponse) context.get("response");
+        VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+        ModelTheme modelTheme = visualTheme.getModelTheme();
         boolean javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request);
         ModelScreenWidget.Menu tabMenu = screenlet.getTabMenu();
         if (tabMenu != null) {
@@ -662,6 +667,8 @@ public class MacroScreenRenderer impleme
         if (subWidget.equals(screenlet.getNavigationForm())) {
             HttpServletRequest request = (HttpServletRequest) context.get("request");
             HttpServletResponse response = (HttpServletResponse) context.get("response");
+            VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+            ModelTheme modelTheme = visualTheme.getModelTheme();
             if (request != null && response != null) {
                 Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
                 globalCtx.put("NO_PAGINATOR", true);

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java?rev=1806134&r1=1806133&r2=1806134&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java Fri Aug 25 08:18:35 2017
@@ -32,6 +32,7 @@ import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilCodec;
 import org.apache.ofbiz.base.util.UtilGenerics;
+import org.apache.ofbiz.base.util.UtilHttp;
 import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.collections.MapStack;
@@ -42,11 +43,13 @@ import org.apache.ofbiz.service.ModelSer
 import org.apache.ofbiz.service.ServiceUtil;
 import org.apache.ofbiz.webapp.view.AbstractViewHandler;
 import org.apache.ofbiz.webapp.view.ViewHandlerException;
+import org.apache.ofbiz.widget.model.ModelTheme;
 import org.apache.ofbiz.widget.renderer.FormStringRenderer;
 import org.apache.ofbiz.widget.renderer.MenuStringRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
 import org.apache.ofbiz.widget.renderer.TreeStringRenderer;
+import org.apache.ofbiz.widget.renderer.VisualTheme;
 import org.xml.sax.SAXException;
 
 import freemarker.template.TemplateException;
@@ -130,6 +133,8 @@ public class MacroScreenViewHandler exte
     public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
         try {
             Writer writer = response.getWriter();
+            VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
+            ModelTheme modelTheme = visualTheme.getModelTheme();
             Delegator delegator = (Delegator) request.getAttribute("delegator");
             // compress output if configured to do so
             if (UtilValidate.isEmpty(encoding)) {