Implemented: Continue the common-theme upload (OFBIZ-9138 Create a common theme)
Four step load the visualTheme in user session, freemarker, screen, groovy and service context Add util to resolve easily a visualTheme git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1806134 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -58,6 +58,8 @@ import org.apache.ofbiz.entity.GenericValue;
|
||||
import org.apache.ofbiz.entity.util.EntityQuery;
|
||||
import org.apache.ofbiz.entity.util.EntityUtilProperties;
|
||||
import org.apache.ofbiz.security.Security;
|
||||
import org.apache.ofbiz.widget.model.ThemeFactory;
|
||||
import org.apache.ofbiz.widget.renderer.VisualTheme;
|
||||
|
||||
/**
|
||||
* Common Services
|
||||
@@ -249,6 +251,18 @@ public class CommonEvents {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Simple event to set the user's per-session theme setting. */
|
||||
public static String setSessionTheme(HttpServletRequest request, HttpServletResponse response) {
|
||||
String visualThemeId = request.getParameter("userPrefValue");
|
||||
if (UtilValidate.isNotEmpty(visualThemeId)) {
|
||||
VisualTheme visualTheme = ThemeFactory.getVisualThemeFromId(visualThemeId);
|
||||
if (visualTheme != null) {
|
||||
UtilHttp.setVisualTheme(request, visualTheme);
|
||||
}
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Simple event to set the users per-session currency uom value */
|
||||
public static String setSessionCurrencyUom(HttpServletRequest request, HttpServletResponse response) {
|
||||
String currencyUom = request.getParameter("currencyUom");
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.apache.ofbiz.entity.GenericValue;
|
||||
import org.apache.ofbiz.security.Security;
|
||||
import org.apache.ofbiz.service.LocalDispatcher;
|
||||
import org.apache.ofbiz.service.ModelService;
|
||||
import org.apache.ofbiz.widget.renderer.VisualTheme;
|
||||
|
||||
/**
|
||||
* A set of <code>ScriptContext</code> convenience methods for scripting engines.
|
||||
@@ -135,6 +136,10 @@ public final class ContextHelper {
|
||||
return (Locale) this.context.getAttribute("locale");
|
||||
}
|
||||
|
||||
public VisualTheme getVisualTheme() {
|
||||
return (VisualTheme) this.context.getAttribute("visualTheme");
|
||||
}
|
||||
|
||||
public Object getParameter(String key) {
|
||||
return getParameters().get(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user