[ofbiz-framework] branch trunk updated: Fixed: 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: Fixed: 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 2d18b93  Fixed: multi-block attribute for html-template tag (OFBIZ-11686)
2d18b93 is described below

commit 2d18b93a2eab5a7d79c6bd336f74d0a8246d93d8
Author: James Yong <[hidden email]>
AuthorDate: Mon Aug 24 07:41:01 2020 +0800

    Fixed: multi-block attribute for html-template tag (OFBIZ-11686)
   
    checkstyle issues
---
 .../org/apache/ofbiz/widget/model/HtmlWidget.java  | 48 ++++++++++------------
 .../widget/model/MultiBlockHtmlTemplateUtil.java   | 35 +++-------------
 2 files changed, 26 insertions(+), 57 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 1a160ad..77a2153 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
@@ -18,20 +18,15 @@
  *******************************************************************************/
 package org.apache.ofbiz.widget.model;
 
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-import javax.servlet.http.HttpServletRequest;
-
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.beans.CollectionModel;
+import freemarker.ext.beans.StringModel;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+import freemarker.template.Version;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilCodec;
@@ -51,15 +46,16 @@ import org.jsoup.nodes.Document;
 import org.jsoup.select.Elements;
 import org.w3c.dom.Element;
 
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.ext.beans.CollectionModel;
-import freemarker.ext.beans.StringModel;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.Version;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
 
 /**
  * Widget Library - Screen model HTML class.
@@ -190,9 +186,7 @@ public class HtmlWidget extends ModelScreenWidget {
     /**
      * Render html template when multi-block=true. We use stack to store the string writer because a freemarker template may also render a sub screen
      * widget by using ${screens.render(link to the screen)}. So before rendering the sub screen widget, ScreenRenderer class will check for the
-     * existence of the stack and retrieve the correct string writer. The following tags are removed from the final rendering: 1. External and inline
-     * javascript tags 2. Css link tags
-     *
+     * existence of the stack and retrieve the correct string writer. Inline script tags are removed from the final rendering.
      * @param writer
      * @param locationExdr
      * @param context
@@ -273,7 +267,7 @@ public class HtmlWidget extends ModelScreenWidget {
 
     public static class HtmlTemplate extends ModelScreenWidget {
         protected FlexibleStringExpander locationExdr;
-        protected boolean multiBlock;
+        private boolean multiBlock;
 
         public HtmlTemplate(ModelScreen modelScreen, Element htmlTemplateElement) {
             super(modelScreen, htmlTemplateElement);
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MultiBlockHtmlTemplateUtil.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MultiBlockHtmlTemplateUtil.java
index 9da9124..bc20bf2 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MultiBlockHtmlTemplateUtil.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MultiBlockHtmlTemplateUtil.java
@@ -18,28 +18,15 @@
  *******************************************************************************/
 package org.apache.ofbiz.widget.model;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
+import org.apache.ofbiz.base.util.UtilGenerics;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.ofbiz.base.util.FileUtil;
-import org.apache.ofbiz.base.util.UtilGenerics;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.select.Elements;
-
 /**
  * Utility to support different handling of code blocks in an html template:
  * 1. Inline javascript tags are turned into external javascript tags for better compliance of Content Security Policy.
@@ -66,18 +53,6 @@ public final class MultiBlockHtmlTemplateUtil {
                     return size() > estimatedConcurrentUserSessions;
                 }
             };
-    /**
-     * For each screen containing html-template, store a set of html imports headerized from html-template.
-     * The set may contain entry of an expression of the the html-template's location.
-     * In this case, we need to expand the location expression before reading the html-template for any html imports.
-     */
-    private static LinkedHashMap<String, Set<String>> htmlLinksForScreenCache =
-            new LinkedHashMap<String, Set<String>>() {
-                private static final long serialVersionUID = 1L;
-                protected boolean removeEldestEntry(Map.Entry<String, Set<String>> eldest) {
-                    return size() > estimatedScreensWithMultiBlockHtmlTemplate;
-                }
-            };
 
     private MultiBlockHtmlTemplateUtil() { }
 
@@ -161,4 +136,4 @@ public final class MultiBlockHtmlTemplateUtil {
     public static void cleanupScriptCache(HttpSession session) {
         scriptCache.remove(session.getId());
     }
-}
\ No newline at end of file
+}