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

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


The following commit(s) were added to refs/heads/release17.12 by this push:
     new 6189bd8  Fixed: Compound-widget not works with condition
6189bd8 is described below

commit 6189bd8dddf6783b2a02d221d586bb0c8baac9be
Author: Jacques Le Roux <[email protected]>
AuthorDate: Mon Apr 27 15:08:40 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.
    
    jleroux: completely backported by hand
    
    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 c80c54d..9af8e64 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
@@ -104,6 +104,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");
@@ -120,11 +123,18 @@ public class GridFactory {
     }
 
     public static ModelGrid createModelGrid(Document gridFileDoc, ModelReader 
entityModelReader, 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, 
dispatchContext, gridLocation, gridName);
     }
 

Reply via email to