If there are duplicate screenlet IDs, then that is a flaw in the screen widget XML file, not in the renderer. In other words, it is caused by user error.

This change is not necessary.

-Adrian

On 1/19/2013 12:27 PM, jler...@apache.org wrote:
Author: jleroux
Date: Sat Jan 19 12:27:25 2013
New Revision: 1435528

URL: http://svn.apache.org/viewvc?rev=1435528&view=rev
Log:
A patch from Sumit Pandit for "HTML Validation error - Duplicate DIV id is created in 
<screenlet title=...></screenlet> tag." 
https://issues.apache.org/jira/browse/OFBIZ-5121

When ID has not been provided in <screenlet title=.../> tag, The generated DIV has an 
ID="_col". Including multiple screenlet in a page get result in multiple DIVs with duplicate ID 
("_col").

For reference find duplicate div id("_col") in following page -
https://demo-trunk.ofbiz.apache.org/catalog/control/EditProdCatalogCategories?prodCatalogId=DemoCatalog


Modified:
     
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1435528&r1=1435527&r2=1435528&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
 (original)
+++ 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
 Sat Jan 19 12:27:25 2013
@@ -74,6 +74,7 @@ public class MacroScreenRenderer impleme
      private int elementId = 999;
      protected boolean widgetCommentsEnabled = false;
      private static final String formrenderer = 
UtilProperties.getPropertyValue("widget", "screen.formrenderer");
+    private int screenLetsIdCounter = 1;
public MacroScreenRenderer(String name, String macroLibraryPath) throws TemplateException, IOException {
          macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath);
@@ -627,11 +628,17 @@ public class MacroScreenRenderer impleme
          }
Map<String, Object> parameters = FastMap.newInstance();
-        parameters.put("id", screenlet.getId(context));
          parameters.put("title", title);
          parameters.put("collapsible", collapsible);
          parameters.put("saveCollapsed", screenlet.saveCollapsed());
-        parameters.put("collapsibleAreaId", screenlet.getId(context) + "_col");
+        if (UtilValidate.isNotEmpty (screenlet.getId(context))) {
+            parameters.put("id", screenlet.getId(context));
+            parameters.put("collapsibleAreaId", screenlet.getId(context) + 
"_col");
+        } else {
+            parameters.put("id", "screenlet_" + screenLetsIdCounter);
+            parameters.put("collapsibleAreaId","screenlet_" + screenLetsIdCounter + 
"_col");
+            screenLetsIdCounter++;
+        }
          parameters.put("expandToolTip", expandToolTip);
          parameters.put("collapseToolTip", collapseToolTip);
          parameters.put("fullUrlString", fullUrlString);



Reply via email to