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

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


The following commit(s) were added to refs/heads/release24.09 by this push:
     new f4966c38bd Fixed: Navigate Accounts fails with a NullPointerException 
when no glAccountId is given (OFBIZ-13651)
f4966c38bd is described below

commit f4966c38bd5670897ed8b23290f2fc15aaa0a6b5
Author: Mridul Pathak <[email protected]>
AuthorDate: Wed Oct 7 17:25:24 2026 +0530

    Fixed: Navigate Accounts fails with a NullPointerException when no 
glAccountId is given (OFBIZ-13651)
    
    The root node of the GlAccountTree is not an entity, so without a 
glAccountId its id was null and a null element was added to the trail of the 
tree, which made the renderer fail while joining it. A root node without an id 
now takes an empty element in the trail, and the trail of the request is split 
without dropping its empty elements, so that the position of the nodes in the 
trail is kept.
---
 .../main/java/org/apache/ofbiz/widget/model/ModelTree.java    | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java
index b67188930c..0e36f3d7e3 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java
@@ -20,6 +20,7 @@ package org.apache.ofbiz.widget.model;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -33,7 +34,6 @@ import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
-import org.apache.ofbiz.base.util.StringUtil;
 import org.apache.ofbiz.base.util.UtilCodec;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilHttp;
@@ -276,10 +276,8 @@ public class ModelTree extends ModelWidget {
         }
         List<String> trail = null;
         if (UtilValidate.isNotEmpty(treeString)) {
-            trail = StringUtil.split(treeString, "|");
-            if (UtilValidate.isEmpty(trail)) {
-                throw new RuntimeException("Tree 'trail' value is empty.");
-            }
+            // an empty element is kept, as it is the id of a root node that 
has none (see ModelNode.renderNodeString)
+            trail = new LinkedList<>(Arrays.asList(treeString.split("\\|", 
-1)));
             context.put("rootEntityId", trail.get(0));
             context.put(getDefaultPkName(context), trail.get(0));
         } else {
@@ -681,7 +679,8 @@ public class ModelTree extends ModelWidget {
                     id = (String) context.get(pkName);
                 }
                 if (currentNodeTrail != null) {
-                    currentNodeTrail.add(id);
+                    // a root node that is not an entity (no pk in the 
context) must still take its place in the trail
+                    currentNodeTrail.add(id == null ? "" : id);
                 }
                 treeStringRenderer.renderNodeBegin(writer, context, this, 
depth);
                 try {

Reply via email to