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

jleroux 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 d7c42e3  Fixed: Compound-widget not works with condition
d7c42e3 is described below

commit d7c42e3b8c77032818d536ba4e0783ee819473b4
Author: Jacques Le Roux <[email protected]>
AuthorDate: Mon Apr 27 14:31:31 2020 +0200

    Fixed: Compound-widget not works with condition
    
    (OFBIZ-11606)
    
    rootElement is not correct for a compound file, it's necessary to do a
    UtilXml.firstChildElement(rootElement, "forms"); to be correct.
    It's done for screen, form but not for grid !
    
    So correction is now added the correct read of rootElement.
    
    Thanks: Olivier
---
 .../main/java/org/apache/ofbiz/widget/model/GridFactory.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java
index 1bfcb87..a7e7653 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java
@@ -118,6 +118,9 @@ public class GridFactory {
         if (gridFileDoc != null) {
             // read document and construct ModelGrid for each grid element
             Element rootElement = gridFileDoc.getDocumentElement();
+            if (!"forms".equalsIgnoreCase(rootElement.getTagName())) {
+                rootElement = UtilXml.firstChildElement(rootElement, "forms");
+            }
             List<? extends Element> gridElements = 
UtilXml.childElementList(rootElement, "grid");
             for (Element gridElement : gridElements) {
                 String gridName = gridElement.getAttribute("name");
@@ -140,11 +143,18 @@ public class GridFactory {
 
     public static ModelGrid createModelGrid(Document gridFileDoc, ModelReader 
entityModelReader, VisualTheme visualTheme,
                                             DispatchContext dispatchContext, 
String gridLocation, String gridName) {
-        Element gridElement = 
UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "grid", "name", 
gridName);
+        Element rootElement = gridFileDoc.getDocumentElement();
+        if (!"forms".equalsIgnoreCase(rootElement.getTagName())) {
+            rootElement = UtilXml.firstChildElement(rootElement, "forms");
+        }
+        Element gridElement = UtilXml.firstChildElement(rootElement, "grid", 
"name", gridName);
         if (gridElement == null) {
             // Backwards compatibility - look for form definition
             gridElement = 
UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "form", "name", 
gridName);
         }
+        if (gridElement == null) {
+            throw new IllegalArgumentException("Could not find grid with name 
[" + gridName + "] in class resource [" + gridLocation + "]");
+        }
         return createModelGrid(gridElement, entityModelReader, visualTheme, 
dispatchContext, gridLocation, gridName);
     }
 

Reply via email to