[ofbiz-framework] branch trunk updated: Improved: multi-block attribute for html-template tag (OFBIZ-11686)

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

[ofbiz-framework] branch trunk updated: Improved: multi-block attribute for html-template tag (OFBIZ-11686)

James Yong-2
This is an automated email from the ASF dual-hosted git repository.

jamesyong pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 91d8a2f  Improved: multi-block attribute for html-template tag (OFBIZ-11686)
91d8a2f is described below

commit 91d8a2f02ab9b7366a722e29feaeba7661468614
Author: James Yong <[hidden email]>
AuthorDate: Mon Sep 28 21:54:25 2020 +0800

    Improved: multi-block attribute for html-template tag (OFBIZ-11686)
   
    Form getJs link according to SEO Config setting
---
 .../main/java/org/apache/ofbiz/widget/model/HtmlWidget.java  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
index c75c06f..fb70871 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
@@ -38,6 +38,7 @@ import org.apache.ofbiz.base.util.cache.UtilCache;
 import org.apache.ofbiz.base.util.collections.MapStack;
 import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
 import org.apache.ofbiz.base.util.template.FreeMarkerWorker;
+import org.apache.ofbiz.product.category.SeoConfigUtil;
 import org.apache.ofbiz.security.CsrfUtil;
 import org.apache.ofbiz.widget.renderer.ScreenRenderer;
 import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
@@ -324,12 +325,17 @@ public class HtmlWidget extends ModelScreenWidget {
                         }
                         String key = MultiBlockHtmlTemplateUtil.putScriptInCache(context, fileName, scripts.toString());
 
+                        HttpServletRequest request = (HttpServletRequest) context.get("request");
                         // construct script link
-                        String webappName = (String) context.get("webappName");
-                        String url = "/" + webappName + "/control/getJs?name=" + key;
+                        String contextPath = request.getContextPath();
+                        String url = null;
+                        if (SeoConfigUtil.isCategoryUrlEnabled(contextPath)) {
+                            url = contextPath + "/getJs?name=" + key;
+                        } else {
+                            url = contextPath + "/control/getJs?name=" + key;
+                        }
 
                         // add csrf token to script link
-                        HttpServletRequest request = (HttpServletRequest) context.get("request");
                         String tokenValue = CsrfUtil.generateTokenForNonAjax(request, "getJs");
                         url = CsrfUtil.addOrUpdateTokenInUrl(url, tokenValue);