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

nmalin 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 1a1c6035ca Fixed: Improve ViewHandler interface (OFBIZ-13179)
1a1c6035ca is described below

commit 1a1c6035ca54efc455fea383a1315572494582f0
Author: Nicolas Malin <[email protected]>
AuthorDate: Wed Nov 12 10:01:50 2025 +0100

    Fixed: Improve ViewHandler interface (OFBIZ-13179)
    
    After the migration on new interface to use the function prepareViewContext 
for FreeMarkerViewHandler, some calls present on groovy class weren't migrate 
and called the older function FreeMarkerViewHandler.prepOfbizRoot.
    
    Thanks Jacques Leroux for the detection
---
 .../src/main/groovy/org/apache/ofbiz/content/cms/CmsEditAddPrep.groovy | 3 +--
 .../main/groovy/org/apache/ofbiz/content/layout/EditSubContent.groovy  | 3 +--
 .../main/java/org/apache/ofbiz/webapp/ftl/FreeMarkerViewHandler.java   | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/applications/content/src/main/groovy/org/apache/ofbiz/content/cms/CmsEditAddPrep.groovy
 
b/applications/content/src/main/groovy/org/apache/ofbiz/content/cms/CmsEditAddPrep.groovy
index 822860141d..44c2a3005d 100644
--- 
a/applications/content/src/main/groovy/org/apache/ofbiz/content/cms/CmsEditAddPrep.groovy
+++ 
b/applications/content/src/main/groovy/org/apache/ofbiz/content/cms/CmsEditAddPrep.groovy
@@ -67,8 +67,7 @@ if (dataResourceId) {
     dataResource = from('DataResource').where('dataResourceId', 
dataResourceId).cache(true).queryOne()
     
SimpleMapProcessor.runSimpleMapProcessor('component://content/minilang/ContentManagementMapProcessors.xml',
             'dataResourceOut', dataResource, contentAssocDataResourceViewFrom, 
[], Locale.getDefault())
-    templateRoot = [:]
-    FreeMarkerViewHandler.prepOfbizRoot(templateRoot, request, response)
+    templateRoot = new FreeMarkerViewHandler().prepareViewContext(request, 
response, null)
     txt = DataResourceWorker.getDataResourceText(dataResource, 'text/html', 
Locale.getDefault(), templateRoot, delegator, true)
 
     if (txt) {
diff --git 
a/applications/content/src/main/groovy/org/apache/ofbiz/content/layout/EditSubContent.groovy
 
b/applications/content/src/main/groovy/org/apache/ofbiz/content/layout/EditSubContent.groovy
index 71c38e1cb6..cabdc23345 100644
--- 
a/applications/content/src/main/groovy/org/apache/ofbiz/content/layout/EditSubContent.groovy
+++ 
b/applications/content/src/main/groovy/org/apache/ofbiz/content/layout/EditSubContent.groovy
@@ -34,8 +34,7 @@ if (currentValue) {
         rootDir = request.getSession().getServletContext().getRealPath('/')
         wrapper = FreeMarkerWorker.getDefaultOfbizWrapper()
         WrappingTemplateModel.setDefaultObjectWrapper(wrapper)
-        templateRoot = [:]
-        FreeMarkerViewHandler.prepOfbizRoot(templateRoot, request, response)
+        templateRoot = new FreeMarkerViewHandler().prepareViewContext(request, 
response, null)
         ctx = [:]
         ctx.rootDir = rootDir
         // webSiteId and https need to go here, too
diff --git 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/FreeMarkerViewHandler.java
 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/FreeMarkerViewHandler.java
index 05df6ea933..680d830afc 100644
--- 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/FreeMarkerViewHandler.java
+++ 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/ftl/FreeMarkerViewHandler.java
@@ -86,7 +86,7 @@ public class FreeMarkerViewHandler extends 
AbstractViewHandler {
 
         // add the request parameters -- this now uses a Map from UtilHttp
         Map<String, Object> requestParameters = 
UtilHttp.getParameterMap(request);
-        if (viewMap.isSecureContext()) {
+        if (viewMap != null && viewMap.isSecureContext()) {
             requestParameters = 
SecuredFreemarker.sanitizeParameterMap(requestParameters);
         }
         root.put("requestParameters", requestParameters);

Reply via email to