This is an automated email from the ASF dual-hosted git repository.
nmalin 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 d14cde118b Improved: Set javascriptEnabled to Y by default
(OFBIZ-13277)
d14cde118b is described below
commit d14cde118b75377b486c0685d2045dcd21c64c52
Author: Nicolas Malin <[email protected]>
AuthorDate: Thu Jul 31 13:30:30 2025 +0200
Improved: Set javascriptEnabled to Y by default (OFBIZ-13277)
When a new user is created, by default at the first connexion a user
preference javascriptEnabled is set to N if the value weren't initialize before.
With modern framework I suggest to reverse the logic and set it to Y.
A better approach would be removed the preference javascriptEnabled because
we can play directly with the theming now, but this represents a lot of work.
So at first step just set Y instead N by default
---
.../main/java/org/apache/ofbiz/base/util/UtilHttp.java | 2 +-
.../org/apache/ofbiz/webapp/control/LoginWorker.java | 16 ++++++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git
a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
index 541d750795..04465aaf9b 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
@@ -1639,7 +1639,7 @@ public final class UtilHttp {
public static boolean isJavaScriptEnabled(HttpServletRequest request) {
HttpSession session = request.getSession();
Boolean javaScriptEnabled = (Boolean)
session.getAttribute("javaScriptEnabled");
- return javaScriptEnabled != null ? javaScriptEnabled : false;
+ return javaScriptEnabled != null ? javaScriptEnabled : true;
}
/**
diff --git
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
index 8eca85f4e0..82aeb329c8 100644
---
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
+++
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java
@@ -597,12 +597,10 @@ public final class LoginWorker {
}
// check on JavaScriptEnabled
- String javaScriptEnabled = "N";
- if ("Y".equals(request.getParameter("JavaScriptEnabled"))) {
- javaScriptEnabled = "Y";
- }
+ String javaScriptEnabled =
"N".equals(request.getParameter("JavaScriptEnabled"))
+ ? "N" : "Y";
try {
- result = dispatcher.runSync("setUserPreference",
UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", "userPrefGroupTypeId",
+ dispatcher.runSync("setUserPreference",
UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", "userPrefGroupTypeId",
"GLOBAL_PREFERENCES", "userPrefValue",
javaScriptEnabled, "userLogin", userLogin));
} catch (GenericServiceException e) {
Debug.logError(e, "Error setting user preference", MODULE);
@@ -701,10 +699,8 @@ public final class LoginWorker {
Map<String, Object> userLoginSession =
checkMap(result.get("userLoginSession"), String.class, Object.class);
// check on JavaScriptEnabled
- String javaScriptEnabled = "N";
- if ("Y".equals(request.getParameter("JavaScriptEnabled"))) {
- javaScriptEnabled = "Y";
- }
+ String javaScriptEnabled =
"N".equals(request.getParameter("JavaScriptEnabled"))
+ ? "N" : "Y";
try {
dispatcher.runSync("setUserPreference",
UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled",
"userPrefGroupTypeId", "GLOBAL_PREFERENCES",
"userPrefValue", javaScriptEnabled, "userLogin", userLogin));
@@ -851,7 +847,7 @@ public final class LoginWorker {
} catch (GenericServiceException e) {
Debug.logError(e, "Error getting user preference", MODULE);
}
- session.setAttribute("javaScriptEnabled",
"Y".equals(javaScriptEnabled));
+ session.setAttribute("javaScriptEnabled",
!"N".equals(javaScriptEnabled));
//init theme from user preference, clean the current visualTheme value
in session and restart the resolution
UtilHttp.setVisualTheme(session, null);