This is an automated email from the ASF dual-hosted git repository.
mridulpathak 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 8fe815b24b Fixed: Navigate Accounts fails with a NullPointerException
when no glAccountId is given (OFBIZ-13651)
8fe815b24b is described below
commit 8fe815b24b2f68ea8bfe70d8a3b4e3da27b6eaf9
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 c0acbfcff6..10e4d6781a 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 {