svn commit: r1862295 - in /ofbiz/ofbiz-framework/trunk: applications/content/src/main/java/org/apache/ofbiz/content/cms/ applications/order/src/main/java/org/apache/ofbiz/order/task/ applications/product/src/main/java/org/apache/ofbiz/product/category/...

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

svn commit: r1862295 - in /ofbiz/ofbiz-framework/trunk: applications/content/src/main/java/org/apache/ofbiz/content/cms/ applications/order/src/main/java/org/apache/ofbiz/order/task/ applications/product/src/main/java/org/apache/ofbiz/product/category/...

mthl
Author: mthl
Date: Fri Jun 28 23:04:54 2019
New Revision: 1862295

URL: http://svn.apache.org/viewvc?rev=1862295&view=rev
Log:
Improved: Add ‘RequestHandler#from’ static method
(OFBIZ-11129)

Avoid some boiler-plate when retrieving the request handler inside a
servlet context.
--this line, and those below, will be ignored--

M    applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
M    applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java
M    applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
M    applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
M    applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
M    framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
M    framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java
M    framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java
M    framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroTreeRenderer.java

Modified:
    ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.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/CoreEvents.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.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/MacroTreeRenderer.java

Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java Fri Jun 28 23:04:54 2019
@@ -286,8 +286,7 @@ public class CmsEvents {
                 templateMap.put("statusCode", statusCode);
 
                 // make the link prefix
-                RequestHandler rh = (RequestHandler) request.getServletContext().getAttribute("_REQUEST_HANDLER_");
-                templateMap.put("_REQUEST_HANDLER_", rh);
+                templateMap.put("_REQUEST_HANDLER_", RequestHandler.from(request));
 
                 //Cache Headers
                 UtilHttp.setResponseBrowserProxyNoCache(response);

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java Fri Jun 28 23:04:54 2019
@@ -21,7 +21,6 @@ package org.apache.ofbiz.order.task;
 import java.util.Locale;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -89,8 +88,7 @@ public class TaskEvents {
 
     /** Accept role assignment event */
     public static String acceptRoleAssignment(HttpServletRequest request, HttpServletResponse response) {
-        ServletContext ctx = request.getServletContext();
-        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+        RequestHandler rh = RequestHandler.from(request);
         Locale locale = UtilHttp.getLocale(request);
 
         if (addToOrderRole(request)) {
@@ -109,8 +107,7 @@ public class TaskEvents {
 
     /** Delegate and accept assignment event */
     public static String delegateAndAcceptAssignment(HttpServletRequest request, HttpServletResponse response) {
-        ServletContext ctx = request.getServletContext();
-        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+        RequestHandler rh = RequestHandler.from(request);
         Locale locale = UtilHttp.getLocale(request);
 
         if (addToOrderRole(request)) {

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/SeoTransform.java Fri Jun 28 23:04:54 2019
@@ -23,7 +23,6 @@ import java.io.Writer;
 import java.util.Iterator;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -90,7 +89,6 @@ public class SeoTransform implements Tem
                     Object prefix = env.getVariable("urlPrefix");
                     if (req != null) {
                         HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
-                        ServletContext ctx = request.getServletContext();
                         HttpServletResponse response = null;
                         if (res != null) {
                             response = (HttpServletResponse) res.getWrappedObject();
@@ -103,7 +101,7 @@ public class SeoTransform implements Tem
                             userLogin = null;
                         }
 
-                        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                        RequestHandler rh = RequestHandler.from(request);
                         out.write(seoUrl(rh.makeLink(request, response, buf.toString(), fullPath, secure, encode), userLogin == null));
                     } else if (prefix != null) {
                         if (prefix instanceof TemplateScalarModel) {

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/UrlRegexpTransform.java Fri Jun 28 23:04:54 2019
@@ -23,7 +23,6 @@ import java.io.Writer;
 import java.util.Iterator;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -90,7 +89,6 @@ public class UrlRegexpTransform implemen
                     Object prefix = env.getVariable("urlPrefix");
                     if (req != null) {
                         HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
-                        ServletContext ctx = request.getServletContext();
                         HttpServletResponse response = null;
                         if (res != null) {
                             response = (HttpServletResponse) res.getWrappedObject();
@@ -103,7 +101,7 @@ public class UrlRegexpTransform implemen
                             userLogin = null;
                         }
 
-                        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                        RequestHandler rh = RequestHandler.from(request);
                         out.write(seoUrl(rh.makeLink(request, response, buf.toString(), fullPath, secure || request.isSecure() , encode), userLogin == null));
                     } else if (prefix != null) {
                         if (prefix instanceof TemplateScalarModel) {

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java Fri Jun 28 23:04:54 2019
@@ -32,7 +32,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -432,8 +431,7 @@ public class ProductSearchSession {
                         if (keywords.contains(ovrdKeyword)) {
                             String targetTypeEnumId = productStoreKeywordOvrd.getString("targetTypeEnumId");
                             String target = productStoreKeywordOvrd.getString("target");
-                            ServletContext ctx = request.getServletContext();
-                            RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                            RequestHandler rh = RequestHandler.from(request);
                             if ("KOTT_PRODCAT".equals(targetTypeEnumId)) {
                                 String requestName = "/category/~category_id=" + target;
                                 target = rh.makeLink(request, response, requestName, false, false, false);

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=1862295&r1=1862294&r2=1862295&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 Jun 28 23:04:54 2019
@@ -1199,9 +1199,9 @@ public class RequestHandler {
         return makeUrl(request, response, url, false, false, false);
     }
 
-    public static String makeUrl(HttpServletRequest request, HttpServletResponse response, String url, boolean fullPath, boolean secure, boolean encode) {
-        ServletContext ctx = request.getServletContext();
-        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+    public static String makeUrl(HttpServletRequest request, HttpServletResponse response, String url, boolean fullPath,
+            boolean secure, boolean encode) {
+        RequestHandler rh = from(request);
         return rh.makeLink(request, response, url, fullPath, secure, encode);
     }
 
@@ -1331,4 +1331,15 @@ public class RequestHandler {
                     return false;
                 });
     }
+
+    /**
+     * Retrieves the request handler which is stored inside an HTTP request.
+     *
+     * @param request the HTTP request containing the request handler
+     * @return a request handler or {@code null} when absent
+     * @throws NullPointerException when {@code request} or the servlet context is {@code null}.
+     */
+    public static RequestHandler from(HttpServletRequest request) {
+        return UtilGenerics.cast(request.getServletContext().getAttribute("_REQUEST_HANDLER_"));
+    }
 }

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java Fri Jun 28 23:04:54 2019
@@ -487,9 +487,7 @@ public class CoreEvents {
     }
 
     public static String streamFile(HttpServletRequest request, HttpServletResponse response) {
-        //RequestHandler rh = (RequestHandler) request.getAttribute("_REQUEST_HANDLER_");
         String filePath = RequestHandler.getOverrideViewUri(request.getPathInfo());
-        //String fileName = filePath.substring(filePath.lastIndexOf("/")+1);
 
         // load the file
         File file = new File(filePath);

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/OfbizUrlTransform.java Fri Jun 28 23:04:54 2019
@@ -23,7 +23,6 @@ import java.io.Writer;
 import java.net.URLEncoder;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -142,10 +141,9 @@ public class OfbizUrlTransform implement
                         return;
                     }
                     if (request != null) {
-                        ServletContext ctx = request.getServletContext();
                         HttpServletResponse response = FreeMarkerWorker.unwrap(env.getVariable("response"));
                         String requestUrl = buf.toString();
-                        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                        RequestHandler rh = RequestHandler.from(request);
                         out.write(rh.makeLink(request, response, requestUrl, fullPath, secure, encode));
                     } else {
                         out.write(buf.toString());

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java Fri Jun 28 23:04:54 2019
@@ -286,7 +286,7 @@ public class IterateSectionWidget extend
         HttpServletRequest request = (HttpServletRequest) context.get("request");
         HttpServletResponse response = (HttpServletResponse) context.get("response");
 
-        RequestHandler rh = (RequestHandler) request.getServletContext().getAttribute("_REQUEST_HANDLER_");
+        RequestHandler rh = RequestHandler.from(request);
 
         writer.append("<table border=\"0\" width=\"100%\" cellpadding=\"2\">\n");
         writer.append("  <tr>\n");

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java Fri Jun 28 23:04:54 2019
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -315,8 +314,7 @@ public class HtmlTreeRenderer extends Ht
             HttpServletRequest request = (HttpServletRequest) context.get("request");
             if (urlMode != null && "intra-app".equalsIgnoreCase(urlMode)) {
                 if (request != null && response != null) {
-                    ServletContext ctx = request.getServletContext();
-                    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                    RequestHandler rh = RequestHandler.from(request);
                     String urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
                     writer.append(urlString);
                 } else {

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=1862295&r1=1862294&r2=1862295&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 Jun 28 23:04:54 2019
@@ -123,7 +123,7 @@ public final class MacroFormRenderer imp
         this.request = request;
         this.response = response;
         this.visualTheme = ThemeFactory.resolveVisualTheme(request);
-        this.rh = (RequestHandler) request.getServletContext().getAttribute("_REQUEST_HANDLER_");
+        this.rh = RequestHandler.from(request);
         this.javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request);
         internalEncoder = UtilCodec.getEncoder("string");
     }

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=1862295&r1=1862294&r2=1862295&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 Jun 28 23:04:54 2019
@@ -84,7 +84,7 @@ public class MacroMenuRenderer implement
                 boolean fullPath = false;
                 boolean secure = false;
                 boolean encode = false;
-                RequestHandler rh = (RequestHandler) request.getServletContext().getAttribute("_REQUEST_HANDLER_");
+                RequestHandler rh = RequestHandler.from(request);
                 src = rh.makeLink(request, response, src, fullPath, secure, encode);
             } else if ("content".equalsIgnoreCase(urlMode)) {
                 StringBuilder newURL = new StringBuilder();

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=1862295&r1=1862294&r2=1862295&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 Jun 28 23:04:54 2019
@@ -29,7 +29,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.WeakHashMap;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.parsers.ParserConfigurationException;
@@ -198,8 +197,7 @@ public class MacroScreenRenderer impleme
                 containerId = getNextElementId();
             }
             HttpServletResponse response = (HttpServletResponse) context.get("response");
-            ServletContext ctx = request.getServletContext();
-            RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+            RequestHandler rh = RequestHandler.from(request);
             autoUpdateLink = rh.makeLink(request, response, autoUpdateTarget);
         }
         Map<String, Object> parameters = new HashMap<>();
@@ -349,8 +347,7 @@ public class MacroScreenRenderer impleme
         String urlString = "";
         if (urlMode != null && "intra-app".equalsIgnoreCase(urlMode)) {
             if (request != null && response != null) {
-                ServletContext ctx = request.getServletContext();
-                RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                RequestHandler rh = RequestHandler.from(request);
                 urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
             } else {
                 urlString = src;
@@ -477,8 +474,7 @@ public class MacroScreenRenderer impleme
                     editRequest += "&amp;";
                 }
                 editRequest += "contentId=" + expandedContentId;
-                ServletContext ctx = request.getServletContext();
-                RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                RequestHandler rh = RequestHandler.from(request);
                 urlString = rh.makeLink(request, response, editRequest, false, false, false);
             }
 
@@ -500,8 +496,7 @@ public class MacroScreenRenderer impleme
         HttpServletRequest request = (HttpServletRequest) context.get("request");
         HttpServletResponse response = (HttpServletResponse) context.get("response");
         if (request != null && response != null) {
-            ServletContext ctx = request.getServletContext();
-            RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+            RequestHandler rh = RequestHandler.from(request);
             fullUrlString = rh.makeLink(request, response, urlString, true, false, false);
         }
 
@@ -592,8 +587,7 @@ public class MacroScreenRenderer impleme
                  if (UtilValidate.isNotEmpty(expandedMapKey)) {
                      editRequest += "&amp;mapKey=" + expandedMapKey;
                  }
-                 ServletContext ctx = request.getServletContext();
-                 RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                 RequestHandler rh = RequestHandler.from(request);
                  urlString = rh.makeLink(request, response, editRequest, false, false, false);
              }
          }
@@ -769,8 +763,7 @@ public class MacroScreenRenderer impleme
             viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
         }
 
-        ServletContext ctx = request.getServletContext();
-        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+        RequestHandler rh = RequestHandler.from(request);
 
         Map<String, Object> inputFields = UtilGenerics.toMap(context.get("requestParameters"));
         // strip out any multi form fields if the form is of type multi

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroTreeRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroTreeRenderer.java?rev=1862295&r1=1862294&r2=1862295&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroTreeRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroTreeRenderer.java Fri Jun 28 23:04:54 2019
@@ -25,7 +25,6 @@ import java.io.StringWriter;
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -324,8 +323,7 @@ public class MacroTreeRenderer implement
 
         if (urlMode != null && "intra-app".equalsIgnoreCase(urlMode)) {
             if (request != null && response != null) {
-                ServletContext ctx = request.getServletContext();
-                RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                RequestHandler rh = RequestHandler.from(request);
                 urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
             } else {
                 urlString = src;